Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Parse Help
Pages: [1] Print
Author Topic: Parse Help  (Read 230 times)
jcale4
Newbie
*
Offline Offline

Posts: 3


View Profile
Parse Help
« on: April 27, 2005, 10:35:56 AM »

Please bear with me as today is my first day using Rebol

I have a file that i export daily and add a .DEL extension (to satisfy DB2). This file has the following dilemiters:

column delim: ~
character delim: {

here is a small section of one line of the file:

99~{text{~3882~{Info      for      product          number{

I need to be able to parse this file and remove the extra spaces between each word in the last column.  I think i know how to actually do the parsing, using "skip" to get to the 4th column and replacing spaces... my problem is that i'm not sure how i create the new, "fixed" file.  Can anyone help me with this?

Thank you!!!
Logged
jcale4
Newbie
*
Offline Offline

Posts: 3


View Profile
Parse Help
« Reply #1 on: April 27, 2005, 10:38:00 AM »

Sorry, forgot that posts are trimmed.  In the example:

99~{text{~3882~{Info for product number{

The column - "Info for product number" has several spaces between each word.
Logged
aRebol
Guest


Email
Parse Help
« Reply #2 on: April 28, 2005, 04:34:20 AM »

rebol []
input: read/lines %/d/program-sources/rebol/test/input.txt
foreach line input [
   parse/all line [3 [thru "{"] begin: copy spacy to "{" end: to end]
   remove/part skip line ((index? begin) - 1) ((index? end) - (index? begin))
   insert at line (index? begin) trim/all spacy
]
write/lines %/d/program-sources/rebol/test/output.txt input
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Parse Help
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2008, 11:35:04 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2287 Posts in 593 Topics by 3732 Members
Latest Member: Hentai40

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc