Hello all, first and foremost I want to apologize if this has been answered somewhere, but I am looking to do the following:

I have 500 records I need put in XML format. The records are currently in CSV format. I can use curl to upload a record in XML format using our applications API. I was under the impression that I could generate 1 large XML file and upload the entire group.

I have a script that will read in data from a CSV and output it to a file in XML format. I got the script the way I thought I needed it working, which was to create a new xml file, append a line to it, then loop through the csv and echo my string repeatedly inputing the variables from the CSV file. I could then upload the XML file where I needed it.

As it turns out, it seems the API will only allow me to upload 1 record at a time. (ALMOST pointless IMO.) So what I am looking to do is change the way the script loops through the CSV file, and instead of creating 1 large file, I would like the script to loop through the CSV one line at a time, create the XML file of only 1 record, upload it using curl, delete itself (or its contents) and repeat that process throughout the entire CSV file.

I am just getting familiar with loops, so Im not sure how I would even start this process, or even word what I want properly to search google. (Which I have been for the last two days, thats how I frankenstiened what I have below. Any help would be greatly appreciated. (Also, just because it bothers me, can anyone help get the line breaks out everytime it echoes a new line?)

What I ended up doing was having the script create 500 separate XML files in a folder by adding my auto increment variable to the XML file name, then curling each file as a separate entry. A litte dirtier than I wanted, but in the end, I didn't have to manually enter 500 subnets and define there locations in a website. Job Done.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum