web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Append Rows to an exis...
Power Automate
Unanswered

Append Rows to an existing CSV template file

(0) ShareShare
ReportReport
Posted on by 32

Hi

I have a use case to generate a CSV file with the data from a SharePoint list. The CSV file is an existing template with the first two rows for Order header and Order line item column names. The data from the Sharepoint list item needs to be populated from the 3rd row onwards. I have seen samples for generating CSV files from scratch but haven't seen any example that appends to an existing CSV file.

 

Any input/direction in this matter is much appreciated.

Thanks.

Categories:
I have the same question (0)
  • Paulie78 Profile Picture
    8,422 Moderator on at

    Can you provide some sample input and desired output, because at the moment it isn't completely clear what the objective is (at least to me).

  • syamknn Profile Picture
    32 on at

    Hi @Paulie78 

    The screenshot below is from a sample CSV file. Here, the first two rows are part of the template, and row 3 onwards populated from 2 lists. Row#3 is populated from one list and Row #3,4,5 are populated from another list (like 1:N relation). 

     

    syamknn_0-1617040555424.png

     

  • syamknn Profile Picture
    32 on at

    Hi @Paulie78  - any idea how to do this?

  • Paulie78 Profile Picture
    8,422 Moderator on at

    Yeah, I have some ideas, it won't be very elegant. This is what I would like you to do, then I will build you a demo.

     

    Do the get items actions you would normally do:

    • One for the Purchase Order Header.
    • One for the Purchase Order Line items.

    Run the flow and go into the run history. Go to both of the Get Items actions and go to "Raw Outputs". Copy and paste the raw outputs from both actions into Pastebin (in separate pastes). Then I will have some data to work with.

     

    Does that make sense?

  • syamknn Profile Picture
    32 on at

    Hi @Paulie78 ,

    Make sense and thanks for the quick response. As instructed, I generated output from the flow and had to clean some confidential info. I have the JSON data for the Header and line items. I haven't seen any option to attach a file here or didn't understand "Pastebin", so trying to paste it directly here. Hope this helps

     

    PO Header

    {
    	"statusCode": 200,
    	"headers": {
    		"Transfer-Encoding": "chunked",
    		"Vary": "Origin,Accept-Encoding",
    		"X-SharePointHealthScore": "3",
    		"X-MS-SPConnector": "1",
    		"X-SP-SERVERSTATE": "ReadOnly=0",
    		"DATASERVICEVERSION": "3.0",
    		"SPClientServiceRequestDuration": "101",
    		"SPRequestGuid": "e867d6e3-8800-48ed-a58e-4421f7e4f9f0",
    		"request-id": "e867d6e3-8800-48ed-a58e-4421f7e4f9f0",
    		"MS-CV": "49Zn6ACI7UiljkQh9+T58A.0",
    		"Strict-Transport-Security": "max-age=31536000",
    		"X-FRAME-OPTIONS": "SAMEORIGIN",
    		"Content-Security-Policy": "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;",
    		"MicrosoftSharePointTeamServices": "16.0.0.21117",
    		"X-Content-Type-Options": "nosniff",
    		"X-MS-InvokeApp": "1; RequireReadOnly",
    		"Timing-Allow-Origin": "*",
    		"x-ms-apihub-cached-response": "true",
    		"Cache-Control": "max-age=0, private",
    		"Date": "Thu, 01 Apr 2021 14:34:45 GMT",
    		"P3P": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"",
    		"X-AspNet-Version": "4.0.30319",
    		"X-Powered-By": "ASP.NET",
    		"Content-Type": "application/json; charset=utf-8",
    		"Expires": "Wed, 17 Mar 2021 14:34:45 GMT",
    		"Last-Modified": "Thu, 01 Apr 2021 14:34:45 GMT",
    		"Content-Length": "1985"
    	},
    	"body": {
    		"@odata.etag": "\"2\"",
    		"ItemInternalId": "119",
    		"ID": 119,
    		"Title": "00000000-040121T102420",
    		"ReqType": {
    			"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    			"Id": 0,
    			"Value": "Expense (N6P)"
    		},
    		"ReqType#Id": 0,
    		"Vendor_x0020_Name": "Blank Vendor to be bid out to LDS",
    		"VendorNumber": "00000000",
    		"BILFINGER": false,
    		"GRCapture_AutoGR": false,
    		"GRCapture_SCForm": false,
    		"GRCapture_WeeklyGR": false,
    		"GRCapture_StoreGood": false,
    		"GRCapture_AutoGR_Update": false,
    		"GRCapture_WeeklyGR_Update": false,
    		"Author": {
    			"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    			"Claims": "",
    			"DisplayName": "",
    			"Email": "",
    			"Picture": "",
    			"Department": null,
    			"JobTitle": null
    		},
    		"Author#Claims": "",
    		"Editor": {
    			"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    			"Claims": "",
    			"DisplayName": "",
    			"Email": "",
    			"Picture": "",
    			"Department": null,
    			"JobTitle": null
    		},
    		"Editor#Claims": "",
    		"IsCrectVendAddress": true,
    		"VendorAddress": "N/A",
    		"Modified": "2021-04-01T14:24:28Z",
    		"Created": "2021-04-01T14:24:27Z",
    		"{Identifier}": "",
    		"{IsFolder}": false,
    		"{Thumbnail}": {
    			"Large": null,
    			"Medium": null,
    			"Small": null
    		},
    		"{Link}": "",
    		"{Name}": "00000000-040121T102420",
    		"{FilenameWithExtension}": "00000000-040121T102420",
    		"{Path}": "Lists/PO Request Info/",
    		"{FullPath}": "",
    		"{HasAttachments}": false,
    		"{VersionNumber}": "2.0"
    	}
    }

     

    PO LineItems

    {
    	"statusCode": 200,
    	"headers": {
    		"Transfer-Encoding": "chunked",
    		"Vary": "Origin,Accept-Encoding",
    		"X-SharePointHealthScore": "0",
    		"X-MS-SPConnector": "1",
    		"X-SP-SERVERSTATE": "ReadOnly=0",
    		"DATASERVICEVERSION": "3.0",
    		"SPClientServiceRequestDuration": "105",
    		"SPRequestGuid": "faf7d4b9-14cd-4dfb-abe7-f644f87fc38c",
    		"request-id": "faf7d4b9-14cd-4dfb-abe7-f644f87fc38c",
    		"MS-CV": "udT3+s0U+02r5/ZE+H/DjA.0",
    		"Strict-Transport-Security": "max-age=31536000",
    		"X-FRAME-OPTIONS": "SAMEORIGIN",
    		"Content-Security-Policy": "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;",
    		"MicrosoftSharePointTeamServices": "16.0.0.21117",
    		"X-Content-Type-Options": "nosniff",
    		"X-MS-InvokeApp": "1; RequireReadOnly",
    		"Timing-Allow-Origin": "*",
    		"x-ms-apihub-cached-response": "true",
    		"Cache-Control": "max-age=0, private",
    		"Date": "Thu, 01 Apr 2021 14:34:46 GMT",
    		"P3P": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"",
    		"X-AspNet-Version": "4.0.30319",
    		"X-Powered-By": "ASP.NET",
    		"Content-Type": "application/json; charset=utf-8",
    		"Expires": "Wed, 17 Mar 2021 14:34:46 GMT",
    		"Last-Modified": "Thu, 01 Apr 2021 14:34:46 GMT",
    		"Content-Length": "5560"
    	},
    	"body": {
    		"value": [
    			{
    				"@odata.etag": "\"1\"",
    				"ItemInternalId": "21",
    				"ID": 21,
    				"Title": "00000000-040121T102420",
    				"POReqID": 119.0,
    				"LineItemDescription": "Frieght",
    				"UOM": "EA",
    				"QTY": "5",
    				"Currency": "USD",
    				"PriceEach": "100",
    				"ItemTotal": "500",
    				"CostCenter": "12345",
    				"CommodityName": "Commercial Parts",
    				"G_x002f_LAccountCode": "51720002",
    				"EndServiceDate": "4/30/2021",
    				"CurrencyChar": "$",
    				"MatCode": "G310000AA",
    				"Modified": "2021-04-01T14:32:25Z",
    				"Created": "2021-04-01T14:32:25Z",
    				"Author": {
    					"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    					"Claims": "",
    					"DisplayName": "",
    					"Email": "",
    					"Picture": "",
    					"Department": null,
    					"JobTitle": null
    				},
    				"Author#Claims": "",
    				"Editor": {
    					"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    					"Claims": "",
    					"DisplayName": "",
    					"Email": "",
    					"Picture": "",
    					"Department": null,
    					"JobTitle": null
    				},
    				"Editor#Claims": "",
    				"GoodOrService": "Good (Item)",
    				"{Identifier}": "",
    				"{IsFolder}": false,
    				"{Thumbnail}": {
    					"Large": null,
    					"Medium": null,
    					"Small": null
    				},
    				"{Link}": "",
    				"{Name}": "00000000-040121T102420",
    				"{FilenameWithExtension}": "00000000-040121T102420",
    				"{Path}": "",
    				"{FullPath}": "",
    				"{HasAttachments}": false,
    				"{VersionNumber}": "1.0"
    			},
    			{
    				"@odata.etag": "\"1\"",
    				"ItemInternalId": "22",
    				"ID": 22,
    				"Title": "00000000-040121T102420",
    				"POReqID": 119.0,
    				"LineItemDescription": "Installation",
    				"UOM": "EA",
    				"QTY": "5",
    				"Currency": "USD",
    				"PriceEach": "500",
    				"ItemTotal": "2500",
    				"CostCenter": "12345",
    				"CommodityName": "Equipment Installation Services",
    				"G_x002f_LAccountCode": "51720003",
    				"EndServiceDate": "4/30/2021",
    				"CurrencyChar": "$",
    				"MatCode": "S811400AA",
    				"Modified": "2021-04-01T14:32:25Z",
    				"Created": "2021-04-01T14:32:25Z",
    				"Author": {
    					"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    					"Claims": "",
    					"DisplayName": "",
    					"Email": "",
    					"Picture": "",
    					"Department": null,
    					"JobTitle": null
    				},
    				"Author#Claims": "",
    				"Editor": {
    					"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    					"Claims": "",
    					"DisplayName": "",
    					"Email": "",
    					"Picture": "",
    					"Department": null,
    					"JobTitle": null
    				},
    				"Editor#Claims": "",
    				"GoodOrService": "Service (Work)",
    				"{Identifier}": "",
    				"{IsFolder}": false,
    				"{Thumbnail}": {
    					"Large": null,
    					"Medium": null,
    					"Small": null
    				},
    				"{Link}": "",
    				"{Name}": "00000000-040121T102420",
    				"{FilenameWithExtension}": "00000000-040121T102420",
    				"{Path}": "",
    				"{FullPath}": "",
    				"{HasAttachments}": false,
    				"{VersionNumber}": "1.0"
    			},
    			{
    				"@odata.etag": "\"1\"",
    				"ItemInternalId": "23",
    				"ID": 23,
    				"Title": "00000000-040121T102420",
    				"POReqID": 119.0,
    				"LineItemDescription": "Support",
    				"UOM": "EA",
    				"QTY": "5",
    				"Currency": "USD",
    				"PriceEach": "100",
    				"ItemTotal": "500",
    				"CostCenter": "12345",
    				"CommodityName": "Equipment Installation Services",
    				"G_x002f_LAccountCode": "51720003",
    				"EndServiceDate": "5/3/2021",
    				"CurrencyChar": "$",
    				"MatCode": "S811400AA",
    				"Modified": "2021-04-01T14:32:25Z",
    				"Created": "2021-04-01T14:32:25Z",
    				"Author": {
    					"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    					"Claims": "",
    					"DisplayName": "",
    					"Email": "",
    					"Picture": "",
    					"Department": null,
    					"JobTitle": null
    				},
    				"Author#Claims": "",
    				"Editor": {
    					"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    					"Claims": "",
    					"DisplayName": "",
    					"Email": "",
    					"Picture": "",
    					"Department": null,
    					"JobTitle": null
    				},
    				"Editor#Claims": "",
    				"GoodOrService": "Service (Work)",
    				"{Identifier}": "",
    				"{IsFolder}": false,
    				"{Thumbnail}": {
    					"Large": null,
    					"Medium": null,
    					"Small": null
    				},
    				"{Link}": "",
    				"{Name}": "00000000-040121T102420",
    				"{FilenameWithExtension}": "00000000-040121T102420",
    				"{Path}": "",
    				"{FullPath}": "",
    				"{HasAttachments}": false,
    				"{VersionNumber}": "1.0"
    			}
    		]
    	}
    }

     

  • Paulie78 Profile Picture
    8,422 Moderator on at

    I've kind of done it, but I cannot see how the fields in the header match up to the fields you want in your CSV though.

  • syamknn Profile Picture
    32 on at

    @Paulie78 - could you please share the PoC you developed. I can refer to that to fit my layout. Thanks.

  • syamknn Profile Picture
    32 on at

    @Paulie78 -any reference. Any input/direction is much appreciated.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard