How do I ignore last whitespace in a line when converting to Pandas DataFrame?
I have a CSV file in the following format:
Column #1 : Type
Column #2 : Total Length
Column #3 : Found
Column #4 : Grand Total
1;2;1;7.00;
2;32;2;0.76;
3;4;6;6.00;
4;1;5;4.00;
I loop through the 'Column #' lines to create my column names first (so 4 columns), then I parse the following lines to create my DataFrame using ';' as the separator. However some of my files contain a trailing ';' on the end of each line as shown above, so my Pandas DataFrame thinks there is a 5th column containing whitespace, and consequently throws an error to say there aren't enough column names specified
Is there a mechanism in Pandas to remove/ignore the trailing ';', or whitespace when creating a DataFrame? I am using read_csv to create the DataFrame.
Thanks.