newline character can't be recognized in the import command

(11 posts) (2 voices)

Tags:

No tags yet.

  1. chadwickhung, Member

    Dear Sir,

    I'm trying to import a tab-delimited file into a report. The file is saved from Excel 'save as' function, After import in MYDBR, the error said "import file does not match the import procedure. Was expecting 17 values, got 2465." So obviously, it can't recognize the newline character, please kindly advise.

    Thanks
    Chadwick

  2. myDBR Team, Key Master

    The tab delimited data cannot have newlines as it would not be possible to detect newlines in the data. Use JSON import for instead.

    --
    myDBR Team

  3. chadwickhung, Member

    Hi DBR team,
    I actually mean the newline character that separates each row. As I save the file in a Mac, the newline is 'CR' which the import command can't recognize it. However, if I save the file again to windows format 'CRLF', the import can recognize newline as a line break and imported it without problem.
    Is there anything to set for Mac, windows or Unix newline ?
    Thanks
    Chadwick

  4. myDBR Team, Key Master

    When you are using tab-delimited import, the line feed (LF, 0x0A) is the newline character. This is the one that Mac and Linux uses. Windows uses CRLF which works also as myDBR ignores the CR.

    --
    myDBR Team

  5. chadwickhung, Member

    But I tried to import the one saved from the excel for Mac, mydbr cannot recognize the line feed, seems like it can only recognize CRLF. May I send you the text file to check?
    Thanks.

  6. chadwickhung, Member

    I've checks some document, they said Mac uses CR as newline, Unix uses LF and Window uses CRLF, if MYDBR skips CR, that's the reason why. Please kindly advise.
    Thanks.

  7. myDBR Team, Key Master

    MacOS X uses LF as newline character as any other Unix system. Last MacOS that used CR was MacOS 9 and that was 16 years ago (days before MacOS X came along). No current system uses CR as linefeeds.

    You can check the Wikipedia.

    --
    myDNR Team

  8. chadwickhung, Member

    With the failed file, if I open it with TextWrangler (text editor) and save it again with linebreak=CRLF or LF, it can be imported to MYDBR.

    So it's the save-as function of MS Excel for Mac which saved the tab delimited file with CR as linebreak. So is it no way for mydbr to recognize CR as linebreak? Is there any option to import CSV instead of tab?
    We're worry that some of our clients are using MAC to get data from their excel sheet and import them into our report.

    Thanks.

  9. myDBR Team, Key Master

    For some unknown reason, Mac Excel chooses to use character encoding (Mac OS Roman) set and linefeeds (CR) that Macs used to use in 16+ years ago when classic MacOS was around. Mac Excel has also no support for Unicode, not in import or export.

    OS X uses Unicode (since 10.2) and LF's (all the time).

    An option is to open the spereadsheet in Apple's Numbers which handles both the encoding and linefeeds correctly.

    Anyways, we'll take a look what we can do about supporting Mac Excel as well. And the support for CSV is coming also.

    --
    myDBR Team

  10. chadwickhung, Member

    OK, Thanks.

  11. myDBR Team, Key Master

    What you can do now, is to set

    auto_detect_line_endings = On

    in php.ini. This will help PHP to recognize the Excel text files using CR as line endings.

    --
    myDBR Team


Reply

You must log in to post.