-
I'm doing a CSV import with Laravel, one specific column is giving me grief. Here is one of the offending rows: ..."Smith, John",John,Smith,11E2,"06 Jun 2007",F,,No,No,No,... The "11E2" is being entered as 1100 into my varchar column in mySql. Here are some steps I tried to figure out where this issue is occurring: https://i.imgur.com/kOekHKQ.png At step one, I did a dump to see how the data was formatted, here is the result: https://i.imgur.com/Yc244Ag.png https://imgur.com/Z1fbCZL.png Great - the data looks correct so far. On step two, the import: I get: Here is the StudentsImport file:
I assume some conversion is happening here because PHP is presuming this is a number? I tried wrapping that column in the csv with quotes, but this did not solve the issue. Do I have to somehow force this as a string? If so, how would I go about doing that? I pass the csv file itself to the import: Everything imports successfully, apart from this. I hope I was clear in my explanation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
PhpSpreadsheet detected 11E2 as a number (11^2) so it makes sense it inserts as 1100. If you want to prevent that, you'll have to tell PhpSpreadsheet that that column is not a number. You can do so via a value binder, or if you want everything to be a string you can use the stringvaluebinder |
Beta Was this translation helpful? Give feedback.
You sir, are a life saver. Thank you Patrick! This did the trick: