This is a long question about CSVs, Excel, Imports and byte-sizes. Here's the rub: I have two completely identical files. They contain exactly the same characters in the same order. One has been opened and saved (Not altered in any way) in Excel. The other has not. The one opened in Excel is 20
bytes larger.
The ERP will only accept the one saved in Excel. Why? More inside.
So, Magento, the e-commerce platform, posts two CSVs everytime someone places an order- One for customer data, one for order data. Right now, we're just looking at the customer data file.
So, it gets this file #_customer.csv. Our ERP, Sage X3, will not take this file. If I export some customer data from Sage, it gives me a file IDENTICAL in all visible ways to the one I tried to upload.
However, if I take that file, open it in Excel and just save it, suddenly it works. The contents of the file does not change, but it does become 20 bytes larger.
Excel has to be doing something, but what? Does anyone have any experience in this? I originally thought it might be an encoding issue, but I double and triple-checked- The Excel saving is the only variable.
This is everything you need to know, but I'm going to describe a few tests I went through below to get to this point just to be thorugh:
The file output, from Magento, looks like this:
A Customer# Order# Category
B First Last Address1 Address 2 Address 3 State Zip Country
D SKU Description Quantatity
D SKU Desciription Quantaity
etc etc.
If I tried to feed that to Sage (Which would Export a file exactly like this), Sage would not take it. If I saved it in Excel, Excel would add a number of empty junk fields so that the number of fields in every row was equal to the number of fields in the largest row MINUS one. In our case, the largest row has TEN fields, so the first row would get 5 extra, empty fields (,,,,, etc.) so that it had a total of NINE fields. D row would get 5, too. A row with 3 would get 6 etc etc.
So, I thought, "Well, that's weird, but whatever. I'll just output x # of junk fields in my CSV". And so I did that. And I got a file visually identical to the file that Sage would accept, thinking that the problem was these junk fields. Still, Sage wouldn't accept it. I had to open it, Save it in Excel and then upload it. It adds about 20 bytes to the file and it works.
The common denominator between these tests: Open and Saving in Excel, adding the 20 bytes. What is Excel up to? I have driven myself to the brink of insanity. Because this needs to be an automated process, I can't open and Save hundreds of files a day. Is this an encoding thing? Help! Save me from CSV hell!
posted by GilloD to technology (34 comments total)
B,CON, ,BIL,NTX,CRC,MAIL
A,BIL,Billing Address,85 North Street, ,Scott,Billyburg,New Jersey,07223,US
A,SHI,Shipping Address,85 North Street, ,Scott,Billyburg,New Jersey,07223,US
D,BIL,Scott
D,SHI,Scott
This one DOES work:
B,CON,,BIL,NTX,CRC,MAIL
A,BIL,Billing Address,85 North Street, ,Scott,Billyburg,New Jersey,07223,US
A,SHI,Shipping Address,85 North Street, ,Scott,Billyburg,New Jersey,07223,US
D,BIL,Scott
D,SHI,Scott
I'm using Notepad++ to view them in Text.
posted by GilloD at 7:29 AM on May 14