This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

data file

Old posts that have not been replied to for several years.
Locked
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

data file

Post by ranny »

Hello,

I have a file.txt with data and i don't know how to write the data who start with letter "G" (for example). I know open and read the file.

Thx for help
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you need to learn at least the basics of Tcl before asking for help with a script; from your question I gather that you don't know a thing about string manipulation (or else you wouldn't be asking how to filter data which starts with a particular letter), so please get back to your Tcl book or/and tcl.tk and learn about [string]
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

when you've done what demond said, here's a quick tutorial on how to write to a file.
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

Post by ranny »

hello,

i have

Code: Select all

[string equal -length [string length $del] $x $del ]
and

Code: Select all

[regexp -all -inline {<td class="row2" align="center"><span class="gensmall">(.+)</span></td>} $body]
it's ok.
but it's possible to make simpler??
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

see FAQ forum, "Parsing webpages made easy"
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

"easy" being a relative term :wink:
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

well yeah hehehe... if you need to parse for just a single or couple of data elements, using tDOM/XPath doesn't make much sense and would be an overkill; however, if you have to implement complex parsing logic and there's good chance for that webpage to change, it would be much easier to go with tDOM and simply adjust XPath as necessary
Locked