开发者

CSV File Import Strangeness: Only Imports if Resaved in Excel

I am a bit dazzled with what is go开发者_开发问答ing on with a csv (.txt) file I am trying to import into MYOB. Using the Drupal CMS, with the views and views bonus modules, I am able to quickly get a feed together that will get the needed fields and drop them into a csv (tab-delimited) txt file.

Here is where the strange issues occurs. If I try to import the file directly into the MYOB program, the records simply are skipped because apparently a field doesn't match the data in the myob file ('tax code when bought field). However, if I open the txt field in Excel, then resave the file (without changing any contents, nothing), and then do the import in Myob, everything works 100%.

I have looked at the source code to check the Content-Type and Content-disposition headers but they are all right.

header('Content-type: text/csv; charset=utf-8'); header('Content-disposition: attachment; filename="[thefilename].txt"');

I've checked to ensure that whitespace and line breaks etc are stripped from the field.

Does anyone have an idea on what may be going wrong here? What I should check for? The workaround works, but just introduces an extra "unnecessary" process.


Please refer to the CSV-1203 File Format Specification. Specifically, refer to Append A "Known issues when using Excel" which explains how Excel can corrupt data without telling you.


I would suggest that Drupal is using unix style line endings (http://en.wikipedia.org/wiki/Newline), and that opening and saving in Excel changes these to Windows style line endings which is what MYOB uses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜