Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: CSV to XML

by 1nickt (Canon)
on May 07, 2021 at 20:27 UTC ( [id://11132241]=note: print w/replies, xml ) Need Help??


in reply to CSV to XML

Hi fmcroft92, welcome to the Monastery and to Perl, the One True Religion.

Your task is common and very simple using existing Perl tools. There will be a learning curve since you are new to the language and programming in general as you said. I suggest you break up your task into chunks and work on them individually rather than trying to get the whole thing done at once.

The anonymonk already pointed you to the two standard toolkits you can use. Why not begin with reading your CSV file into a Perl data structure that you'll later convert to XML? You'll need to install Text::CSV_XS and code like:

use strict; use warnings; use Text::CSV_XS 'csv'; use Data::Dumper; use feature 'say'; my $array_of_hashes = csv( in => '/path/to/file.csv', headers => 'auto +'); say Dumper $array_of_hashes; # Now loop through each hash and convert to XML

Hope this helps!


The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found