Jump to content

Count Records


step

Recommended Posts

Is "countRecords" limited to only external data files? I have a job that I would like to count the number of records of my internal data file on an OnJobStart rule but the following code doesn't yield any results when I run a Print line command:

 

var rec = FusionPro.Composition.recordCount;

Link to comment
Share on other sites

Is "countRecords" limited to only external data files? I have a job that I would like to count the number of records of my internal data file on an OnJobStart rule but the following code doesn't yield any results when I run a Print line command:

 

var rec = FusionPro.Composition.recordCount;

That's not a valid property of the FusionPro.Composition object.

 

No, there's nothing built-in to count the number of records in your main data file before the composition starts. And the actual number of lines in the data file isn't necessarily the same as the number of records you're going to compose anyway, because you might be skipping or repeating records.

 

You could, of course, load your main input data file (if it's a delimited "flat" data file and not tagged) with ExternalDataFileEx and count the records that way. But you need to know the delimiter in the rule.

 

What are you trying to do with the number of records?

Link to comment
Share on other sites

I admit that I find it odd that there's not a way to count records in the primary data file. Doesn't FP have to do this during composition when imposing with a stacked layout? Why treat primary data differently than external data?
Link to comment
Share on other sites

I admit that I find it odd that there's not a way to count records in the primary data file. Doesn't FP have to do this during composition when imposing with a stacked layout?

Yes, FusionPro does a preprocessing step to determine the total number of records for "infinite" stacking (and for personalized images). But that's not exposed via JavaScript, and even if it was, that would only apply to jobs with doing this preprocessing step. And again, it's not about the number of records in the data file, it's about the number or records that are actually composed, taking skips and repeats into account.

 

Also, preprocessing can greatly slow down the composition, especially for larger jobs with tens or hundreds of thousands of records, since it has to read the entire data file twice. The regular way that FusionPro works, without preprocessing, is that it just reads the input data file and composes output records as it reads them in, until it gets to the end. (It looks at the size of the file and how far along it is in reading it in bytes to estimate the total number of records during composition, but getting the file size is a lot faster than reading the whole file in a preprocessing step.)

 

Perhaps there could be an option, exposed to JavaScript, which forces preprocessing, then returns the total number of records to be composed. We're actually considering this for a future release. Again, though, it would help to focus the enhancement request, or I might be able to suggest something else, if I knew exactly what the ultimate goal was.

Why treat primary data differently than external data?

These files are treated differently by definition. The primary data file is what drives the composition and largely determines the number of records being composed, and their order. The external data file API in JavaScript, however, simply exposes a way to randomly access a delimited data file. FusionPro has no knowledge of how you're going to use the data in the file; that's up to whatever JavaScript logic you write. So how you treat the secondary data file is up to you, not to FusionPro.

Link to comment
Share on other sites

Perhaps there could be an option, exposed to JavaScript, which forces preprocessing, then returns the total number of records to be composed. We're actually considering this for a future release. Again, though, it would help to focus the enhancement request, or I might be able to suggest something else, if I knew exactly what the ultimate goal was.

 

I was attempting to create some what of a work-around for the problem I was discussing here. I created a script that would determine an imposition of best fit for a particular order of business cards based on the number of unique cards (records). I did this by bringing the internal data file in as an external data file.

 

Since I can't get FusionPro to call FPI files based on that information, I just appended it to the end of the file name (24up) and that let's me know that I need to drop the non-imposed PDFs into a hot folder with an applied imposition at our Indigo press.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...