Read through CSV file uploaded under 'assets' in repository

Hi All,

Is there a way to read through CSV file uploaded under ‘/content/assets’? I want to do it through scheduler job. Please let me know how we can do it. Any example code snippet would be a great help.

Thanks
Rahul

The data will be in a binary property on the asset node. Note that the node structure will be handle->asses set node → asset node. From the asset node you can get the binary property, from which you can get a stream. Then you need to parse that stream.

Hi do you have a code exmaple for this, as I am struggling to understand what you have written and how to get the content out?

Bit more context.

I have a CSV file uploaded as an asset. It is linked to a document.

HippoAssetBean csvFile = (HippoAssetBean)blockDocument.getCsvFile();
HippoResourceBean resource = csvFile.getAsset();
log.info(“Resource File:” + resource.getName() + " has a length of:" + resource.getLength());
returns the length of the file.

However how do I get the input stream from this?

thanks
J

resource.getNode().getProperty("project:property") .getBinary().getStream()

Something like that should work.

Is there a way to read the csv file from updater script?

I am trying to read csv file and update the document.

Thank you.

You should have access to any node from an updater. Even beyond the node you get from the query or path you used for the updater. Once you have a jcr node or session you can find any other node if you know the path.