[Swift-user] readData is treating line as a single field

Ketan Maheshwari ketan at mcs.anl.gov
Mon Jan 13 11:46:40 CST 2014


Hi Mike,

I am not sure how to introduce a field separator to readData(). I tried
adding '|' between header and data fields but seems readData is complaining
that file header does not match type and it expected space separated items:

File header does not match type. Expected 4 whitespace separated items. Got
5 instead.
swiftscript:readData, quadui-multi.swift, line 27



On Mon, Jan 13, 2014 at 11:05 AM, Wilde, Michael J. <wilde at mcs.anl.gov>wrote:

>  Did you try different field separators? I think in the past Ive used
> spaces. Perhaps the readData() code is not sufficiently white-space-aware
> yet?
>
>  - Mike
>
>
>  --
> Michael Wilde
> Mathematics and Computer Science          Computation Institute
> Argonne National Laboratory                    The University of Chicago
>
>     ------------------------------
> *From:* swift-user-bounces at ci.uchicago.edu [
> swift-user-bounces at ci.uchicago.edu] on behalf of Ketan Maheshwari [
> ketan at mcs.anl.gov]
> *Sent:* Monday, January 13, 2014 11:01 AM
> *To:* Swift User
> *Subject:* [Swift-user] readData is treating line as a single field
>
>   Hi,
>
>  I am trying to use readData() function in Swift to read fields into a
> Swift structure but seems it is reading the whole line as a single field.
>
>  Here is my text file for the data:
>
>  $ cat data.txt
> Survey_data Strategy_data Field_data quadui_outdir
> /home/kcm92/faceit-pipeline/FIXED_ACE_DOME/ACCESS1/4.5/MID/EMBU/Survey_data_import_fixed.zip
> /home/kcm92/faceit-pipeline/FIXED_ACE_DOME/ACCESS1/4.5/MID/EMBU/Seasonal_strategy_fixed.zip
>  /home/kcm92/faceit-pipeline/FIXED_ACE_DOME/ACCESS1/4.5/MID/EMBU/Field_Overlay_fixed.zip
> /home/kcm92/outdir_1
> /home/kcm92/faceit-pipeline/FIXED_ACE_DOME/ACCESS1/4.5/MID/ISHIARA/Survey_data_import_fixed.zip
> /home/kcm92/faceit-pipeline/FIXED_ACE_DOME/ACCESS1/4.5/MID/ISHIARA/Seasonal_strategy_fixed.zip
> /home/kcm92/faceit-pipeline/FIXED_ACE_DOME/ACCESS1/4.5/MID/ISHIARA/Field_Overlay_fixed.zip
> /home/kcm92/outdir_2
>
>  I have 4 fields and 2 rows.
>
>  Here is the structure definition:
>
>  type Data{
>     string Survey_data;
>     string Field_data;
>     string Strategy_data;
>     string quadui_outdir;
> }
>
>  Here is the Swift loop that I am using to process this data:
>
>  Data d[] = readData(@arg("data"));
> /* run quadui */
> foreach ditem in d{
> tracef("Survey data is: %s", ditem.Survey_data);
>  }
>
>  In the output, I get the whole first row of the file instead of the
> expected first field.
>
>  Any clues?
>
>  Thanks,
> Ketan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20140113/3104b733/attachment.html>


More information about the Swift-user mailing list