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

Re^2: Write array contents to csv file

by learner@perl (Novice)
on Jul 11, 2013 at 14:11 UTC ( #1043734=note: print w/replies, xml ) Need Help??

in reply to Re: Write array contents to csv file
in thread Write array contents to csv file


$empid contains numeric value like 12 and @array contains values like Name DOB DOJ Country Place Salary, i am pushing all the values from $empid and @array to @report using join and all values are tab delimited

i used the code below and executed

my $line = join /\t/ , ($empid, @array); push @report, $line;

Output i got as below

Name DOB DOJ Country Region Salary Place JKSLK1989010120000101FranceALMERIA100000.00BCFGHK

Output expected

Name DOB DOJ Country Region Salary Place JKSLK 1989010120000101 France ALMERIA 100000.00BCFGHK

i am trying to write this output to csv file, how can i do that, any solution please

Replies are listed 'Best First'.
Re^3: Write array contents to csv file
by poj (Prior) on Jul 11, 2013 at 14:27 UTC

    Are you viewing the csv file in Excel ? If so, rename it to report.xls and then see what you get.


      I can see the expected data, but after renaming the file from .csv to .xsl, i hope the data is saved in Text(Tab delimited, when i click on the .xsl file, its throwing an warning message like format is not supporting, the message is the file is in a different format than specified


        Excel xls format isn't the same as csv, so when you change a csv file extension to xls attempting to open it in Excel will fail. Excel should open csv files, if you actually want an Excel file see Spreadsheet::WriteExcel.

        If it is tab delimited why are you giving it the file extension .csv. ? I said xls not xsl. Anyway, what does the file look like in a text editor like notepad++.

        Update: If the message is 'The file you are trying to open is in a different format than specified by the file extension....Do you want to open the file now ? then select 'Yes'.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043734]
[LanX]: Thx found a solution! :)
[Eily]: I wrote "your" instead of "you're" :'(
[Eily]: I guess it means that my English is good enough that I make the same mistakes as native speakers though :/
[LanX]: your native tounge is French .... or Quebequois?
[erix]: never mind the natives
[Eily]: French, why?
LanX ' solution
[LanX]: lately you were talking about kids confused with "la liason"
[LanX]: I stopped worrying about my pronounciation and orthography "problems" in English
[Eily]: ah yes, you asked about the value of neuros :)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-03-27 16:04 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.