Excel – going wrong with importing and formatting the following .csv data set into Excel

csvformatformattingmicrosoft excel

I'm trying to import the following CSV data set into Excel. I'm using the Text Import Wizard to set the right delimiters. So far, I used the ";" and "," delimiters.

Here is the result so far. The data set seems to be looking fine, until row 493. From that point on, the data changes from the year 2014 to 2015. Somehow, the format of the data seems to have changed somewhat from that point on, resulting in a CSV file in which the columns are not aligned anymore.

Here's a snapshot of what happens:

enter image description here

Question: what should I do to format this CSV data set in such a way that its columns are neatly aligned in Excel?

Best Answer

The file is malformed at line 494, where the record seems to be just a fragment.

This is how it looks in notepad++:

enter image description here

It seems like there is spurious line-feed that splits line 493 in two. Manually joining lines 493 and 494 might fix the problem for this line (I haven't tried to import it).

However, this line is not the only one. You should look for lines starting with ", as all of them seem to belong to the preceding lines.

Using notepad++, the following Replace All operation might fix all the lines:

  • Find what : \n"
  • Replace with : "
  • Search mode : Extended

enter image description here