I'm trying to read a csv
file but my csv files differ. Some have different format and some have other. I'm trying to add controls so that I will not need to edit my code or my input file.
My problem is, some of these csv files have a line of String above the column headers. An example:
Created on 12-11-2018,CryptoDataDownload.com
Date,Symbol,Open,High,Low,Close,Volume From,Volume To
2018-12-11 11-AM,ADABTC,8.6e-06,8.61e-06,8.55e-06,8.57e-06,301141.7,2.59
2018-12-11 10-AM,ADABTC,8.69e-06,8.72e-06,8.6e-06,8.6e-06,236949.63,2.05
If I import this, the delimeter will use the first line and separate the file into two columns as Created on 12-11-2018
and CryptoDataDownload.com
.
This is how df.head()
looks like:
Created on 12-11-2018 CryptoDataDownload.com
Date Symbol Open High Low Close Volume From Volume To
2018-12-11 11-AM ADABTC 8.6e-06 8.61e-06 8.55e-06 8.57e-06 301141.7 2.59
2018-12-11 10-AM ADABTC 8.69e-06 8.72e-06 8.6e-06 8.6e-06 236949.63 2.05
2018-12-11 09-AM ADABTC 8.7e-06 8.7e-06 8.62e-06 8.69e-06 509311.39 4.41
2018-12-11 08-AM ADABTC 8.69e-06 8.7e-06 8.63e-06 8.7e-06 111367.34 0.9656
I want to check if this file has this line and skip it if so.
How can I do this?