Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The point i was trying to make was that the user shouldnt have to leave the web page environment, but should only have to choose which file they want to view the data of.

The user doesnt want to see any of the actual raw data, but merely an overall graph to display the data on the screen in a graphical format that can easily be understood.

** not meaning to be arsey about it :)****

I may be a bit stupid but can you tell me of a way that i can loop through all the column headings in the file (say writing them to the screen), i.e. stored in an array, then for each row do the same. Currently i have the following code, although i know it doesnt work. I was thinking of a hash table for the column and value but im new to this perl game. The problem i have is to recognise the number of columns there are and loop through each row upto and including the last column, then go to the next line and start again. My brain is wrecked at this stage. Im normally a java programmer and cant seem to see a way forward....HELP!.

# read from a file and extract the contents into an Excel file sub write_to_Excel() { use Spreadsheet::WriteExcel; my @columnNames; my @rowValues; my $count = 0; my $row = 0; my $fileArray = "F:/User_Interface/dbStuff/ArrayExpress.txt"; open( INFILE, "<$fileArray") or die "Cannot open the file"; print("Searching File..."); foreach $line ( <INFILE> ) { if( $line =~ /^Name/ ) { @columnNames = split(/\t/, $line); } else { @rowValues = split(/\t/, $line); } } # Create a new workbook and save a file called example.xls # and add a worksheet called Summary to that. my $workbook = Spreadsheet::WriteExcel->new("ArrayExpress.xls"); my $worksheet = $workbook->add_worksheet(`Summary`); # Set text bold, red, underlined for values # designated as high # my $high_val = $workbook->add_format(); # $high_val->set_bold(); # $high_val->set_color(`red`); # $high_val->set_underline(); ###### not sure how to loop through array to put rows across then do +wn and same with cols $worksheet->write($row,$count,$element); foreach $element(@columnNames) { $count++; $worksheet->write($row,$count,$element); } foreach my $element(@rowValues) { $worksheet->write($row,$count,$element); $count++; $row++; } }

Sorry about the mess with the node changing. Again im new to this.
MonkPaul.


In reply to Re^3: Converting a txt file to excel file by MonkPaul
in thread Converting a txt file to excel file by MonkPaul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-25 18:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found