ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Problem with writing number of records in file

Post new topic  Reply to topic
 Problem with writing number of records in file « View previous topic :: View next topic » 
Author Message
Frik
PostPosted: Mon Nov 05, 2012 4:09 am    Post subject: Problem with writing number of records in file Reply with quote

Acolyte

Joined: 25 Nov 2009
Posts: 69

Hello,
I need to write csv file with:
1. Header (written once - first line in file)
2. Unknown numbers of records.

I'm doing it by reading a big file (couple of Mbs...),
reading it with FileInput Node with records options on, so I'm reading 1000 records every time (size of a records is 50, so it's configures to 50000).

It works realy well, but the problem is that in the header i have to write the number of the total records, which I don't know when I'm reading the file (because I read 1000 records).

Any fast and good solution?
is there a way to update the first record after i wrote it?

Thanks.
Back to top
View user's profile Send private message
ah.khalafallah
PostPosted: Sun Mar 03, 2013 3:15 am    Post subject: Reply with quote

Newbie

Joined: 03 Mar 2013
Posts: 5

Hi Frik,

as far as from what I understood,

it's only a one-file meaning it's one-time run
so you can set this field to the CARDINALITY function's output when you give it the Data Array in the Parsed Message.

but if it's done multiple runs, you need to read the last file you written and update the field by incrementing the value in the No. of Records in it with the number of records each time.
Back to top
View user's profile Send private message MSN Messenger
Vitor
PostPosted: Sun Mar 03, 2013 5:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

ah.khalafallah wrote:
so you can set this field to the CARDINALITY function's output when you give it the Data Array in the Parsed Message.


If the file's being read 1000 records at a time then (as the OP pointed out) this will return 1000 not the true value. The question of if this is the best way to read a file like this is a separate topic....

ah.khalafallah wrote:
but if it's done multiple runs, you need to read the last file you written and update the field by incrementing the value in the No. of Records in it with the number of records each time.


The OP knows that; he's asking how you update a record already written.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Sun Mar 03, 2013 5:25 am    Post subject: Re: Problem with writing number of records in file Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Frik wrote:
is there a way to update the first record after i wrote it?


Why does the header need to the first record you write out? Why not write it out when the last data record has been processed and use your favorite sort utility to move it to the top before the consuming application processes it?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Problem with writing number of records in file
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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.