• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Load Text file and display in table format.

 
sohail sam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to test the javascript code, this is what i did, but it says error.



html

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is your code not indented for readability?
 
sohail sam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the code you enter isn't indented, code tags will not provide the indentation. The code tags will preserve the already-resident indentation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic