aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Load Text file and display in table format. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Load Text file and display in table format." Watch "Load Text file and display in table format." New topic
Author

Load Text file and display in table format.

sohail sam
Greenhorn

Joined: Nov 05, 2009
Posts: 4
I wish to display the output in a nice table format, the text file contains loads of rows and columns and each column separates either by space " " or "," .
Please can someone help, at the moment it says, Problem retrieving data. Unknown

Further I am not sure if i need a webserver to make this work, as currenlty all html files are stored on a network drive and everything works fine except this section.


I wish to display the output in a nice table format, the text file contains loads of rows and columns and each column separates either by space " " or ",".
Please can someone help, at the moment it says, Problem retrieving data. Unknown

Further I am not sure if i need a webserver to make this work, as currenlty all html files are stored on a network drive and everything works fine except this section
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no need to make all your text red. Rather annoying to read.



You can use split(\n/) to break up the lines

You can use split(/(\s|,)/)

You can either loop or you can do a join

I would do something like



Code is untested, I am sure you can figure it out if there is any bugs.

Eric
sohail sam
Greenhorn

Joined: Nov 05, 2009
Posts: 4
Hi,

Million thanks, i tried the coee but it doesn't work, please can someone help.

my text file looks something like this:

abc123, 234 pqr,xyz "type"
bc123, 234 pqr,xyz "type"
c123, 234 pqr,xyz "type"
n23, 234 pqr,xyz "type"
aj23, 234 pqr,xyz "type"

As you notice, it has got "," aswell a blank space and ""..



sohail sam
Greenhorn

Joined: Nov 05, 2009
Posts: 4
Just to test the javascript code, this is what i did, but it says error.



html

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Why is your code not indented for readability?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sohail sam
Greenhorn

Joined: Nov 05, 2009
Posts: 4
I don't know why? I havn't got a clue, i just did as it was advised,
use {code} tags for the script. please let me know if you know anything of we need to follow any specific way to add script between code tags.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

If the code you enter isn't indented, code tags will not provide the indentation. The code tags will preserve the already-resident indentation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Load Text file and display in table format.