<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Write huge CSV File in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147263#M38971</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Are you creating many versions of the CSV file ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;--C.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2022 19:30:02 GMT</pubDate>
    <dc:creator>cesarista</dc:creator>
    <dc:date>2022-11-02T19:30:02Z</dc:date>
    <item>
      <title>Write huge CSV File</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147262#M38970</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have to write a huge csv file from some information coming from an AFTS query. At this moment, the query is already working and I got the correct information to create the CSV file.&lt;/P&gt;&lt;P&gt;My problem here is creating the CSV file with lots of information (around 300.000 rows).&lt;/P&gt;&lt;P&gt;This is my method to query and write the results:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;private void &lt;/SPAN&gt;&lt;SPAN&gt;writeInitialReport&lt;/SPAN&gt;(String pathResolved&lt;SPAN&gt;, &lt;/SPAN&gt;FileInfo csvFileInfo) &lt;SPAN&gt;throws &lt;/SPAN&gt;IOException {&lt;BR /&gt;    writeHeader(csvFileInfo)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    StringBuilder sb&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    boolean &lt;/SPAN&gt;hasMore&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    int &lt;/SPAN&gt;count = &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    do &lt;/SPAN&gt;{&lt;BR /&gt;        SearchParameters searchParameters = &lt;SPAN&gt;buildQuery&lt;/SPAN&gt;(pathResolved)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;        searchParameters.setSkipCount(count+=&lt;SPAN&gt;INTERVAL&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;        searchParameters.setMaxItems(&lt;SPAN&gt;INTERVAL&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;        ResultSet resultSet = &lt;SPAN&gt;serviceRegistry&lt;/SPAN&gt;.getSearchService().query(searchParameters)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;        if &lt;/SPAN&gt;(resultSet != &lt;SPAN&gt;null&lt;/SPAN&gt;) {&lt;BR /&gt;            sb = &lt;SPAN&gt;new &lt;/SPAN&gt;StringBuilder()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;            for &lt;/SPAN&gt;(NodeRef nodeRef : resultSet.getNodeRefs()) {&lt;BR /&gt;                buildRow(sb&lt;SPAN&gt;, &lt;/SPAN&gt;nodeRef)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            }&lt;BR /&gt;            hasMore = resultSet.hasMore()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;            ContentReader contentReader = &lt;SPAN&gt;serviceRegistry&lt;/SPAN&gt;.getContentService().getReader(csvFileInfo.getNodeRef()&lt;SPAN&gt;, &lt;/SPAN&gt;ContentModel.&lt;SPAN&gt;PROP_CONTENT&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            ByteArrayOutputStream content = &lt;SPAN&gt;new &lt;/SPAN&gt;ByteArrayOutputStream()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            content.write(contentReader.getContentInputStream().readAllBytes())&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            content.write(sb.toString().getBytes())&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;            ContentWriter contentWriter = &lt;SPAN&gt;serviceRegistry&lt;/SPAN&gt;.getContentService().getWriter(csvFileInfo.getNodeRef()&lt;SPAN&gt;, &lt;/SPAN&gt;ContentModel.&lt;SPAN&gt;PROP_CONTENT&lt;/SPAN&gt;&lt;SPAN&gt;, true&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            contentWriter.setMimetype(MimetypeMap.&lt;SPAN&gt;MIMETYPE_TEXT_CSV&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            contentWriter.setEncoding(&lt;SPAN&gt;"UTF-8"&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;            contentWriter.putContent(&lt;SPAN&gt;new &lt;/SPAN&gt;ByteArrayInputStream(content.toByteArray()))&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;        } &lt;SPAN&gt;else &lt;/SPAN&gt;{&lt;BR /&gt;            hasMore = &lt;SPAN&gt;false;&lt;BR /&gt;&lt;/SPAN&gt;        }&lt;BR /&gt;    } &lt;SPAN&gt;while &lt;/SPAN&gt;(hasMore)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I'm using docker. I don't know why, but before I execute this, my docker volume contains 1.7Gb. After this execution, my volume passes to 7Gb. The created excel file has around 20Mb.&lt;/P&gt;&lt;P&gt;So, why is alfresco creating so many data?&lt;/P&gt;&lt;P&gt;Could it be because of the way I'm writing into the file? I can't get all the data in one variable because I get an Out of memory exception.&lt;/P&gt;&lt;P&gt;And the putContent method from the ContentWriter seems to always replace the existing data with the new data. So, I'm reading the old data, appending the new data and then write to the csv.&lt;/P&gt;&lt;P&gt;Can you advise on this?&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Francisco Duarte&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 15:58:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147262#M38970</guid>
      <dc:creator>franciscoduarte</dc:creator>
      <dc:date>2022-11-02T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Write huge CSV File</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147263#M38971</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Are you creating many versions of the CSV file ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;--C.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 19:30:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147263#M38971</guid>
      <dc:creator>cesarista</dc:creator>
      <dc:date>2022-11-02T19:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Write huge CSV File</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147264#M38972</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I don't know if writing this way creates other versions. Anyway, when I visit the document, it says version 1.0.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Francisco Duarte&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 10:32:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147264#M38972</guid>
      <dc:creator>franciscoduarte</dc:creator>
      <dc:date>2022-11-09T10:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Write huge CSV File</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147265#M38973</link>
      <description>&lt;P&gt;I totally like your gave limits as some information which is totally essential for me.&amp;nbsp;&lt;A href="https://www.paymydoctor.ltd/" target="_self" rel="nofollow noopener noreferrer"&gt;PayMyDoctor Portal&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 07:19:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/write-huge-csv-file/m-p/147265#M38973</guid>
      <dc:creator>Jenlop</dc:creator>
      <dc:date>2022-11-14T07:19:12Z</dc:date>
    </item>
  </channel>
</rss>

