Is there is way to read CSV file in confluence user macro? I want to read each column value?
Asked by Mohamed Asan:

Hi All,

I am new to the confluence and working small requirement. I want to read CSV/txt file from local computer and do some manipulation on that read value before displaying confluence page. Is there any way we can do this using User macro or with predefined function?

Your answers will help me lot to meet my deadline.

Thanks lot,

Mohamed Asan


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hello Mohamed,

There's a new [Table from](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+from+CSV+macro)[CSV](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+from+CSV+macro) macro you could try in the Table Filter and Charts app. This macro allows you to output a table from CSV or TSV data source on the Confluence page.  
By the way, Table from CSV supports outputting data not only from an attached file but also from a URL. And you can use the following data formats: Wiki markup, Markdown, Plain text.  

Here's an example of how to use it and manipulate data with the [Table Transformer](https://docs.stiltsoft.com/display/TFAC/How+to+use+Table+Transformer+macro) macro then:  

1. Add Table from CSV on the Confluence page.  

![Screenshot_1.png](https://community.atlassian.com/t5/image/serverpage/image-id/94026i9633CCD0B1122F03/image-size/large?v=v2&px=999 "Screenshot_1.png")![Screenshot_3.png](https://community.atlassian.com/t5/image/serverpage/image-id/94028i918CB8B7AFFB561C/image-size/large?v=v2&px=999 "Screenshot_3.png")

Type in the name of the CSV file from Confluence attachments and click insert.

![Screenshot_2.png](https://community.atlassian.com/t5/image/serverpage/image-id/94027i0F78F7E1194F7F99/image-size/large?v=v2&px=999 "Screenshot_2.png")

The table loaded:

![Screenshot_4.png](https://community.atlassian.com/t5/image/serverpage/image-id/94031i7979023F76686FEA/image-size/large?v=v2&px=999 "Screenshot_4.png")

<br />

2. Wrap the manually created table and Table from CSV with the Table Transformer macro.

<br />

![Screenshot_5.png](https://community.atlassian.com/t5/image/serverpage/image-id/94029iA4165033B62E9529/image-size/large?v=v2&px=999 "Screenshot_5.png")

Choose the preset needed or write your own SQL query.  

![Screenshot_6.png](https://community.atlassian.com/t5/image/serverpage/image-id/94032iC46ADDA198DD7DCE/image-size/large?v=v2&px=999 "Screenshot_6.png")![Screenshot_7.png](https://community.atlassian.com/t5/image/serverpage/image-id/94033iFB32EE655901B373/image-size/large?v=v2&px=999 "Screenshot_7.png")![Screenshot_8.png](https://community.atlassian.com/t5/image/serverpage/image-id/94034iCD2D38F77A849EFC/image-size/large?v=v2&px=999 "Screenshot_8.png")

Using both Table from CSV and Table Transformer you can load a file and manipulate its data.

Katerina  
StiltSoft

comments: author: ofer ROZENBERG
body: hi

is there a way to configure the csv name dynamically, if for example i use Confiforms ?

i attach file to form entry and would like that a user will be able to use different file not pre defined in the macro


author: Alex Medved _ConfiForms_
body: Probably you can use ConfiForms ListView to show the data from your form and put the advised macro inside the macro body, in this macro body you can access ConfiForms field values via \[entry.field_name\] notations that can be passed (and evaluated to values first) to "inner macros"

Alex


author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Ofer Rozenman](/t5/user/viewprofilepage/user-id/2285988)  

I am not sure that understood your use case. Could you clarify it, provide more details?  

Would you like to have the whole list of attachments available in the Attachment with CSV box right away?

Katerina


author: Anup
body: Why don't you just upload the file to Confluence ***after*** you're finished with it?

comments: author: Mohamed Asan
body: Hi Anup,

The motivation is to automate the process. The file will be created by back end system in CSV format. And need to read to the file and put some extra content and formatting to display into the confluence page.

Thanks,

Mohamed Asan


author: Anup
body: If you can use a Google sheet for your purpose then you could use a Sheets macro (free add-on available to download) to display it. Any modifications to the sheet would reflect on the Confluence page as it sort of acts like an iframe.