Skip to content

Instantly share code, notes, and snippets.

@clairezed
Created September 18, 2017 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clairezed/c21fb505188f47a68f186e9f1271bee9 to your computer and use it in GitHub Desktop.
Save clairezed/c21fb505188f47a68f186e9f1271bee9 to your computer and use it in GitHub Desktop.
import pandas as pd
import datetime
import csv
from collections import defaultdict
source_file = "tech_grand_est_00.csv"
dest_file = "tech_grand_est_01.csv"
df = pd.read_csv(source_file,
sep=',' ,
error_bad_lines=False,
encoding='iso-8859-1',
quoting=csv.QUOTE_NONE
)
print "Begining =============================================================="
df.columns = df.columns.str.replace('\"','')
df.columns = df.columns.str.replace("\r",'')
# Verification
print df.columns
print df[:10]
print len(df)
# Selection des departements qui intéressent
# type des departements pas clair.
df = df.loc[df['DEPET'].isin([
88, 54, 55, 57, 67, 68, 70, 52, 10, 51, 8, 90,
'88', '54', '55', '57', '67', '68', '70', '52', '10', '51', '8', '08', '90'
])]
df.to_csv(dest_file, sep=',', encoding='utf-8', index=False)
print "Ended ================================================================"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment