Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Convert ISO 9660 filesystem image to ASCII text

by rajan (Novice)
on May 10, 2013 at 12:10 UTC ( #1032948=perlquestion: print w/ replies, xml ) Need Help??
rajan has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks: I have an issue during a file conversion from XML to CSV. I derive values from the XML file and write it into a CSV file (using perl file handler). The CSV file should be of "ASCII text" format, but I get it in a format "ISO 9660 filesystem image". Can you please help me on, how to change the format to ASCII text ?

my $path = '/opt/finance/File1'; my $PMN = 'KKDDI'; my $MON = 'DDIID';my $YEAR ='2013';my $MON='JAN';my $DATE='12' my $CSV = $path . '.csv'; open CSV, ">$CSV" || die "Cannot open the file $CSV $! \n"; print CSV "\"ABCDE501,\"\"$PMN\"\",$MON/01/$YEAR,$MON/$DATE/$YEAR,$MON +/$DATE/$YEAR\"\n"; # Data hash contains values that has to be printed. foreach my $key (keys %DataHash) { print CSV $DataHash{$key}; } close(CSV);

Comment on Convert ISO 9660 filesystem image to ASCII text
Download Code
Re: Convert ISO 9660 filesystem image to ASCII text
by roboticus (Canon) on May 10, 2013 at 14:28 UTC

    rajan:

    I'd suggest mounting the ISO image and then see if it contains the file in the format you expect.

    If you're on a *nix system, it's pretty straightforward, and there are methods for mounting ISO images on Windows as well.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Convert ISO 9660 filesystem image to ASCII text
by BrowserUk (Pope) on May 10, 2013 at 14:43 UTC

    Are you saying that the file you are creating with your code above is being identified as an "ISO 9660 filesystem image" by some program (browser)?

    If so, the fix lies with correcting that program that is associating ".csv" with "ISO 9660 filesystem image". Nothing in your program is creating a ISO image.

    IE. this is not a Perl problem.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Convert ISO 9660 filesystem image to ASCII text
by InfiniteSilence (Curate) on May 10, 2013 at 18:11 UTC

    On Perlmonks you need to close your open code tags or else your post's formatting will be nigh unreadable. Also, your code doesn't make much sense:

    #my $path = '/opt/finance/File1'; + my $path = q|/tmp/File1|; my $PMN = 'KKDDI'; my $MON = 'DDIID'; my $YEAR ='2013'; my $MON='JAN'; my $DATE='12'; my $CSV = $path . '.csv'; open CSV, ">$CSV" || die "Cannot open the file $CSV $! \n"; print CSV "\"ABCDE501,\"\"$PMN\"\",$MON/01/$YEAR,$MON/$DATE/$YEAR,$MON +/$DATE/$Y\ EAR\"\n"; # Data hash contains values that has to be printed. + foreach my $key (keys %DataHash) { print CSV $DataHash{$key}; } close(CSV);

    Here you are writing the header to the CSV in a specific order but you are iterating willy-nilly over a hash which is not guaranteed to produce results in that same order.

    perl -e 'my %hash = (q|first|=>1,q|third|=>3,q|second|=>2); print key +s %hash;' firstsecondthird

    Celebrate Intellectual Diversity

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1032948]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2014-09-18 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (105 votes), past polls