Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Relax
Newbie


Joined: 05 Sep 2005
Posts: 9

PostPosted: Mon Oct 10, 2005 3:50 pm   

%read with quoted CSV files
 
I'm getting nowhere fast on this issue.

I have a text file, containing entries like

;1-3
"A shaggy ape-like humanoid is resting here.","1-42","Taer","1-3","AggVis","","","",""
;1-5
"A large, round ball of fungus rolls around here.","1-42","Ascomoid","1-5","AggVis","","","","Blind"

If I read a line with %read, the quote get stripped. but I can get around this doing:

#FILE 1 "wellmobs.dat"
#ECHO %1 has %filesize( 1) lines.
#LOOP 1,%filesize( 1) {
parse_csv_temp="%read( 1)"
; At this stage, string is surrounded by quotes.
#ECHO @parse_csv_temp
}
#CLOSE 1

Howeve, as soon as I try to do anything with parse_csv_temp, I lose my quotes. Problem 2 is I want to then pump the line through an alias, but the alias sees all of @parse_csv_temp in %1, rather than splitting at the commas in the variable. I've tried with normal alias and %alias syntax.

I think the main problem is how the data is intially read.

Any help greatly appreciated.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Oct 10, 2005 5:24 pm   
 
I'm not sure exactly what your doing that you lose your quotes reparse @parse_csv_temp. Can you give an example?

Second what exactly do you mean by pump the line through an alias? If you send the entire quoted line then you should expect the entire line to be in the variable. If you want to pull out a particular piece of information from the line you will need to parse it out from the quoted line. Please post more information on this.

%read reads the variables delimited by quotes. If you're saying you don't need the quotes, as suggested by your second problem, and just want to capture the variable values and pump through an alias then I would go back to using %read without quoting the line before you put it into a variable. If you explicitly need the quotes, use the %read and explicitly add the quotes when passing it into your alias.

I may have completely missed what you are trying to get down, if I have please describe exactly what you are trying to do with the data you read in (and your code to do so thus far).
_________________
Asati di tempari!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Oct 10, 2005 10:39 pm   
 
#FILE 1 "wellmobs.dat"
#ECHO %1 has %filesize( 1) lines.
#LOOP 1,%filesize( 1) {
parse_csv_temp="%read( 1)"
; At this stage, string is surrounded by quotes.
#ECHO %stripq(%replace(@parse_csv_temp,%concat(%char(34),","),"|"))
}
#CLOSE 1

That change should allow displaying the variable contents as a zMud string list; with just the proper comma delimeters changed, and all quotes removed. As to the 'pumping through an alias' I don't really see the point of passing a known variable. If splitting the code from your reading alias into another is a logical maneuver for readability there is no reason to pass the variable. That code already knows the variable and can access it directly.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Relax
Newbie


Joined: 05 Sep 2005
Posts: 9

PostPosted: Tue Oct 11, 2005 10:55 pm   
 
Thanks for the feedback, I'd made some incorrect assumptions, I'll get back to this post in a few days - I'm trying a different approach now.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net