cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Write(load) data into flat file.

mohan_salla
Participant
0 Likes
1,632

Dear Experts,
I have to load the data into a flat file and atleast leave first 4 rows blank(I meant say that Data should be written

into file from 5th row onwards in flat file).See below screenshot.


Could anybody advise me asap.

Thanks&Regards
Mohan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi Mohan,

I suggest to split your workflow in two steps. First you connect the object "Row_Generation" with a query to your flatfile. Set the amount of rows to 4. It will generate 4 lines with an ID field.

In the output schema of your query you can fill the fields with NULL or blank as needed.

In the second step you export your data as usual.

Regards

Jürgen

mohan_salla
Participant
0 Likes

Thank you for your kind advise and appreciated for your help.

This is not working as I expected.

Suppose source data table has 100 rows and I want to export it to .txt file. I am expecting to see 4 blank rows + 5th row should be column headers and 100 rows.

Could you please send me atl if possible,

Kind regards

Mohan

Former Member
0 Likes

Hi,

Not tried, but should work i guess. There is an option in the file format editor 'Skip rows'. You can enter a value there to skip rows.

Have you tried that?

The easiest option would be to insert a post load command with SQL query in a template table and convert template table to text file.

Thanks,

Arun

mohan_salla
Participant
0 Likes


Hi Jürgen,

I tried as you advised but it's keep on over writting first 4 rows and start loading from 1st row and never loaded the data after 4 rows as expected.I have changed flatfile properies skip rows etc..but no use. Please could you please advise me.

thanks

mohan

Answers (5)

Answers (5)

Former Member
0 Likes

hi..mohan.

I have designed a job based on your requirement .

In query write ifthenelse statement .as below to get the 5th row as header

mohan_salla
Participant
0 Likes

Thank you so much guys for your kind help. Both (Jürgen &Ancy) scenarios were tried and worked as expected.  Thanks alot to Jurgen & Ancy.

Rishabh_Awasthi
Active Participant
0 Likes

Hi Mohan,

Skip rows opton of the File Format would not serve the requirement as it will skip the specified number of rows of the existing rows of the data being loaded.

Keep the data load flow normal with the Skip row header as NO and Load the data into a file .

After the load into the file join a Script to the data flow executing unix command to prepend the new line to the existing file.

Flow:

Dataflow--->Script.

Unix script can perform following steps :

  • Move the content of the existing file with data to a temp file,
  • add the required number of line to the existing file,
  • append the data from the temp file.

But this scenario could take time if the file being loaded is huge.

So better would be to get a Unix script to prepend lines to existing file without using the temp file.

Regards,

Rishabh

Former Member
0 Likes

Hi Mohan,

Did you try looking into the options in File Format Editor? Please look into the attachment.

Cheers

Nagabhushanam G

Former Member
0 Likes

Hi Mohan,

Use a BODS script to insert new lines into the file before calling them in DF.
For eg: (if Windows)

In script have :

1)delete the prev run target file present in folder

2) Insert new line to file.

exec('cmd','for %1 in (1 2 3 4) DO echo.>> C:\Users\A\Desktop\M1.txt',8);

3)After script have the DF with target text file with Write row headers enabled and delete file assigned to 'No'.

Now the target should have 4 newlines before the row header.

Similary if the OS is unix have unix command to insert new line.

Thanks,
Ancy