I am trying to find a solution for determining the row count for a .csv file that is loaded as a document in my Appian Knowledge center, without having to convert the document into data by importing the content of the .csv file into my database. I have not been able to find any solutions when reviewing the Appian Documents or Community pages, so I am seeking any input or creative solutions to assist.
For reference, the business process we are solving here is "user uploads the .csv file to Appian, and we act as an intermediary to transfer the file via an integration API to another system". As part of the file transfer, we need to send the row count to ensure no rows were lost in transmission; we are trying to solve for a way to determine the row count without asking the user to type it in (since this is a bad UX) and without having to load the .csv file into the Appian database (since the structure of the file's content will change over time, and we don't want to have to keep changing any Appian CDTs to parse the data and determine the row count).
Thanks in advance!-Rob
Discussion posts and replies are publicly visible
CSV can be treated/read as a text file. You could use a plugin that simply reads lines from a text file. The output of the plugin would be a List of Dictionary so you would not need a CDT and the length of the list will be your row count. As a best practice make sure you specify a fixed limit or batch size when reading from the file.
Here is a sample lightweight expression using the Text File Reader plugin on AppMarket - no CDT or database involved:
a!localVariables( local!csvContents: readtextfromfile( txtFile: todocument(<your uploaded csv doc id>), preserveLineBreaks: true() ), local!rowCount: length(split(local!contents, char(10))), local!rowCount )