0

I have a CSV file with data for a table in a mySQL database. I'm using phpMyAdmin to import the data. It all works fine except for one major issue. It randomly cuts off the text fields. There doesn't seem to be any reason about when.

  1. They are all at different points (i.e. not a specific number of characters).
  2. Not every row cuts the fields off.
  3. It cuts off at a space character (i.e. "The man crossed the road, and saw a tree." turns into "The man")
  4. There are two different fields that cut off.
  5. When I import the table data, each time the fields that get cut off, get cut off at the same point every time.
  6. If I remove the space where the row/field gets cut off, it loads more of the text (sometimes all the rest, sometimes cutting off at a different point).

Anyone seen a similar issue and have a resolution?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Michael Reiland
  • 849
  • 3
  • 8
  • 19
  • I would suggest you to use `LOAD DATA INFILE` : http://dev.mysql.com/doc/refman/5.1/en/load-data.html And also check this : http://stackoverflow.com/a/24170168/1788704 – kmas Jun 25 '14 at 13:27
  • When I try to use that, it only loads the first row. – Michael Reiland Jun 25 '14 at 14:13
  • Try TERMINATED BY \r or \r\n. http://stackoverflow.com/questions/2215544/load-data-infile-only-1-record-inserted – kmas Jun 25 '14 at 14:34

1 Answers1

1

I figured out what was happening here. There were embedded characters that were leftovers from the original Word file. Somehow, Textedit and even other text editing tools were not displaying them correctly, but they were there. Thus, when the import tool reached them it just freaked out I guess and stopped loading the field at that point. Once I removed all these characters, it loaded fine.

Michael Reiland
  • 849
  • 3
  • 8
  • 19