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

Re^5: adding an index column to a csv data file

by poj (Abbot)
on Jun 03, 2019 at 17:43 UTC ( [id://11100896]=note: print w/replies, xml ) Need Help??


in reply to Re^4: adding an index column to a csv data file
in thread adding an index column to a multi-array derived from a csv data file

You could build the array while reading the data

#!/usr/bin/perl use strict; use warnings; my @AoA = (); # ArrayOfArrays while (<DATA>){ s/\s//g; my @tmp = split ',',$_; $tmp[0] *= 1.0; $tmp[1] /= 1.0; $tmp[2] = $.; push @AoA,\@tmp; } printf "%e,%e,%d\n",@$_ for @AoA; __DATA__ 0.00000000e+00, 2.41644835e+00 1.20048018e-04, 2.38938189e+00 2.40096037e-04, 2.36473989e+00
poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-23 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found