• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Load Text file and display in table format.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to test the javascript code, this is what i did, but it says error.



html

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is your code not indented for readability?
 
sohail sam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic