Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

As a rule of thumb, DOS, Windows, OS/2 and many internet protocols use CR+LF, classic Macs use CR only, Unix and its derivates including modern Macs and the remaining internet protocols use LF only. They all use ASCII. Things become worse on EBCDIC systems, typically made by IBM. See Newlines in perlport.

Look at a hex dump of the export, it will surely help more than guessing.

od -t x1c demo.csv 0000000 22 48 65 61 64 69 6e 67 20 31 22 2c 22 48 65 61 " H e a d i n g 1 " , " H e +a 0000020 64 69 6e 67 20 32 22 2c 22 48 65 61 64 69 6e 67 d i n g 2 " , " H e a d i n +g 0000040 20 33 22 2c 22 48 65 61 64 69 6e 67 20 34 22 0d 3 " , " H e a d i n g 4 " \ +r 0000060 0a 22 44 61 74 61 20 31 22 2c 22 44 61 74 61 20 \n " D a t a 1 " , " D a t a 0000100 32 22 2c 22 44 61 74 61 20 33 22 2c 22 44 61 74 2 " , " D a t a 3 " , " D a +t 0000120 61 20 34 22 0d 0a 22 4d 6f 72 65 20 31 22 2c 22 a 4 " \r \n " M o r e 1 " , +" 0000140 4d 6f 72 65 20 32 22 2c 22 4d 6f 72 65 20 33 22 M o r e 2 " , " M o r e 3 +" 0000160 2c 22 4d 6f 72 65 20 34 22 0d 0a , " M o r e 4 " \r \n 0000173

This particular CSV file ends each line with two bytes 0x0D and 0x0A, which is equal to \015\012 on ALL platforms. If you read the file on a Unix-based system or in binary mode on a DOS-based system, you can also use \r\n. If you read the file in text mode on a DOS-based system, use only \n. You can get the same behaviour on Unix-based system using the :crlf PerlIO layer.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^5: parsing csv with Text::ParseWords by afoken
in thread parsing csv with Text::ParseWords by GertMT

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-18 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found