Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Perl Issue - File downloaded in windows has a Control M character in it??

by aitap (Deacon)
on Oct 24, 2012 at 19:08 UTC ( #1000692=note: print w/replies, xml ) Need Help??


in reply to Perl Issue - File downloaded in windows has a Control M character in it??

After our troubleshooting, we found out that the file downloaded by newer version come with empty rows between data, since the .csv files came with spaces (empty rows), it is not being processed and fails.
If a UNIX-newlined text file is read as DOS-newlined textfile, it looks like there is no newlines at all because DOS newline is "\r\n" when UNIX newline is just "\n".

So there is no way of empty lines appearing because of UNIX-newlined file being viewed as DOS-newlined. Can you provide a small hexdump of a damaged file?

Sorry if my advice was wrong.
  • Comment on Re: Perl Issue - File downloaded in windows has a Control M character in it??

Replies are listed 'Best First'.
Re^2: Perl Issue - File downloaded in windows has a Control M character in it??
by Anonymous Monk on Oct 24, 2012 at 19:37 UTC
    what is hexdump? we are working on windows... when i used the command call unix2dos, i am getting the output i needed...but i cant use the unix2dos utility...all i need to do is using perl only...
      Hexdump is a hexadecimal representation of bytes in a file. You can obtain it by running something like this:
      open my $f,"<:raw","file.csv" || die $!; my $c; for (1..8) { for (1..16) { read $f,$c,1 || exit 0; print unpack "H2",$c; } print "\n"; }
      You can rewrite unix2dos in Perl using PerlIO :crlf output layer.
      Sorry if my advice was wrong.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000692]
help
Chatterbox?
[Discipulus]: and milano is our mitteleuropa part..
[choroba]: then an old man came who had a valid ticket to the same compartment and they fought
[Corion]: hippo: Yeah, I might take that one so I don't get out of London too late if it comes to that ;)
[choroba]: she called carabinieri, the train had to stop and we had to testify to them. But we didn't miss the plane in the end.
[karlgoethebier]: good morning *
[Discipulus]: miracle choroba! and unbelivalbe carabinieri understood you
[choroba]: They even sent me a letter whether I'd be willing to come to Milano to testify in the court
[choroba]: I replied with "yes" but the trial never happened
[Discipulus]: dont be so sure choroba.. 11 years is not too long for an Eatalian judgement
[choroba]: I've moved to Prague in the meantime, they can't reach me anymore :-)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2017-11-20 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (286 votes). Check out past polls.

    Notices?