View-Headers-And-Edit-CSV

If a file is too large to be opened by Excel or Notepad, this script will read the csv file and allow a user to output a clean csv


In [ ]:
import pandas as pd
print (pd.__version__)

In [ ]:
response = input("Please Enter Location of Input CSV (""Example: C:\Test\TestCSV.csv)"": ")

The code below will read the csv, show you any errors and skip over those lines. The data frame object is then passed below.


In [ ]:
# If you need to see what pandas read is all about here is the call for the help
#df = pd.read_csv?

df = pd.read_csv(response,error_bad_lines=False, index_col=False, encoding='iso-8859-1',warn_bad_lines=True)
datakeys = df.keys()
datakeys
df

Put in the location for the new csv


In [ ]:
newcsv = input("Please Enter Location of output CSV (""Example: C:\Test\TestCSV.csv)"": ")

The section below will allow you to put in values that you want replaced in the output csvs.


In [ ]:
newdf = df.replace(to_replace =["None", "none", "NONE"],  
                            value ="") 
export_csv = newdf.to_csv((newcsv), index = None, header=True)