Tideway Community Forum

forgot password?
   
 
read each line of a discoveredFile using a pattern
Posted: 21 October 2008 08:19 AM   [ Ignore ]  
Newbie
Rank
Total Posts:  3
Joined  2008-01-27

I want to process a csv file that I have discovered by processing at the contents of each line. I was trying to use regexExtractAll with the regex ‘.\n’ which I know will give me each file, but the pattern compilation engine removes the ‘.‘ meaning that my regex won’t work.

Does anyone have any better ideas?

Profile
 
 
Posted: 21 October 2008 09:48 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  132
Joined  2008-01-25

Did you qualify the string as a regex?

regex '*.\n' 

If you need to process each line you might be better off spliting the file.contents on the newline and looping over each line.

for line in text.split(file1.contents"\n") do
  if 
regex.extract(lineregex "foo"then
    
//do stuff;
  
else;
    
//do something else;
end for; 

Profile
 
 
Posted: 21 October 2008 10:55 AM   [ Ignore ]   [ # 2 ]  
Newbie
Rank
Total Posts:  3
Joined  2008-01-27

Yeah splitting on ‘\n’ works, that’s exactly what I want to do. I had asked the client to put a ‘|’ character at the end of the line, and was splitting on that, but have now replaced this with ‘\n’.

Cheers.

Profile