Flat File Delimiter Issue

I created a generic Flat File Schema template to test writing out a flat file that was fixed position. (columns 0-3 are id, 4-10 are data). I wrote it out (using the Sample.IO package file handlers, not the inherent, and as far as I can tell undocumented, outputFileName field in convertToString) to a file and everything looked fine. However, according to the ConvertToString documentation, I can set record, field, and sub-field delimiters. When I set these values in the ConvertToString flow, however, it doesn’t do anything. It’s the same output no matter what I put in these fields. Has anyone gotten these delimiters to work? If so, what do I need to do to get them to work? If I pass multiple records to convertToString, it handles it fine, except that it ignores my delimeters.

Any help would be great! I’m stuck!

Jamie Stanton
Innotrac

I believe you specify the delimiters in the template.

Well, normally, there are two types of flat file formats, either fixed length (position-based) or delimited (with delimiter). If you want to output fixed-length file, you don’t need delimiters…will look at it later…

You will find the answers to your questions in developer\plugins\flatfileplugin\doc\ISFlatfileSchema.pdf.

If you are using 6.0.01 youwill find a shockwave demo file showing you (step-by-step) how to do what you are trying to do. Access to the demo is via the home page icon of the WmFlatFileSamples package under the Manager hyperlink of the Administrator Browser.

Hmmmm… I don’t have the WmFlatFileSamples package, so I’m guessing I haven’t picked up 6.0.01 yet. I’ll look for that. From what y’all are saying, though, I’m guessing that I have to pick one or the other. Which is generally fine, with the exception of a record delimiter, which is quite useful even in fixed position formats by placing a newline after each record. I tried adding a “dummy” 1 character field to the record and defaulting it’s value to \n, but that didn’t work. I just got the "", it didn’t seem to want to read it as a single character. I can do it the hard way, looping and only ever passing 1 record to the convertToString method, but that seems limiting. Is there anyway that I can tell it to put a newline after each record of my fixed position flat file? Thanks for all your help!

Jamie Stanton
Innotrac

\n is a special literal that is automatically converted to 0x0a by compilers and sometimes by services within the wM IS environment (e.g. convertToString will convert it when passed as one of the delimiter parameters).

If you wish to use \n (or \r, \t, etc.) outside of these cases, you have to do the conversion yourself. Do a search in wmusers.com for “toChar” which is a service that will do this conversion for you. You can place the resulting char in your dummy record field.

Thanks Rob! That did it. I added an extra field called newLine to my record that was 1 character long, used toChar and it worked great. Thanks everyone!

Jamie Stanton
Innotrac

Hi! I was very pleased to read your messages here, I’m having the same problem: a flat file with fixed lenght, but after every record a carriage return must be added.
What I did so far: in the schema I added a dummy field in each record, I filled this field with the outcome of the toChar service.
This doe not work for me??
Any suggestions?

Claire, if you are using the schema editor in wm 6.01, try this.
on the Flat File Definition tab
under Record Parser select Delimiter
Under Record select Character and in the selection box select Newline from the drop down.

Hi ,
I am facing the opposite problem… I have my record parser as Delimiter. The record delimiter that I am using is a newline. However, the convertToString service is adding an extra delimiter to all my records…i.e, all the records are separated by two newlines. Help me out!

Salonia,

Did you tried with carriagereturn as well?,unless you set extra delimiter convertToString dont add extra delimiter.Please make sure.

HTH,
RMg

Hi rmg,
Yes, I tried with carriage return, but that too did not work. I have not added extra delimiter anywhere, just defined the delimiter once in the schema. Is this some bug with convertToString…??
Saloni

Are you moving the file between Unix and Windows?
Take a look at the file in an Hex editor like debug on windows or Ultraedit. You probably have embedded carriage return/line Feed in the file.

hth

I need some help. I´ve created a flat file schema but I still have delimiters problems.

I need to retrieve some data (for exemple: 001) after a specific string : order 001

Remembering that I have an amount of data together : id 102 order 001 date 230407

Any ideas how to do it?

Thanks

Please elaborate more about your FFSchema details?? Is your flatfile is fixed-length and delimited?? If it is fixed length you can specify start/end positions and extract the value??

HTH,
RMG

Hi,

It´s delimited. I cannot use fixed-length because the amount of data could be variable. I believe the solution is getting the data after an specific word. :frowning:

Vivian,

Will the data always appear in the same location? For example, in the sample you provided: id 102 order 001 date 230407

id comes first, order comes second, and date comes third. Will that always be the case?

If so, then you could use a flat file schema with a delimiter (a space, it appears) and then always assume that the 4th field is the order ID (in this case, 001).

If not, then I don’t know that using the flat file schema to break down the fields will really buy you much. You might be better off just reading each line, passing the entire line to the service pub.string:tokenize, and then loop over the tokens. Once you find the token that you’re looking for (in this case, the word order), you can assume that the next token is the value you need.

Let me know if this makes sense.

  • Percio

Hi Percio! How u doing?

Perfect! That´s the idea! I´ll try this using pub.string:tokenize!

Thanks a lot!
Vivian

But if you use pub.string:tokenize then you got to do lot of manipulation to extract the values incase you file has lot of rows/lines…its ok if you are satisfied doing this.just curious.

Is this solution not feasible for you ie. to put in the Schema side which was told above??
"id comes first, order comes second, and date comes third. Will that always be the case?"

HTH,
RMG

Hello,

Data does not appear in the same location. But now… how to specify the string I´m looking for?

Tks
Vivian