Create new CSV from specific columns in existing CSV

jtouchais

New Member
Joined
Jun 7, 2018
Messages
1
Hi Experts!

I have an order export from my store producing a CSV file with set columns that I cannot change prior to the export (ORDER_EXPORT)
My warehouse requires a csv file in order to receive the orders with a different set of columns (headers and order of the data) (SHIPPER_CSV)

What I would need is a script that:
1. map the headers correctly (e.g. Shipping Name > recipient_name)
2. imports the data from ORDER_EXPORT to the correct SHIPPER_CSV columns
3. if ORDER_EXPORT header "Shipping Company" is not blank then SHIPPER_CSV "recipient_type" = B else SHIPPER_CSV "recipient_type" = C
3. saves SHIPPER_CSV as a .csv that can be imported

I have dabbled a little in VBA but it was a long time ago. Moreover i am not familiar with CSV and it's text strings instead of ranges...

Help please! :)

PS - below is the mapping I did of the headers for reference.
[TABLE="width: 500"]
<tbody>[TR]
[TD]ORDER_EXPORT[/TD]
[TD]SHIPPER_CSV[/TD]
[/TR]
[TR]
[TD]Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Email
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Financial Status
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Paid at
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fulfillment Status
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fulfilled at
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Accepts Marketing
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Currency
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Subtotal
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Shipping
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Taxes
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Total
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Discount Code
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Discount Amount
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Shipping Method
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Created at
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem quantity
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem price
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem compare at price
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem sku
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem requires shipping
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem taxable
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem fulfillment status
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Street
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Address1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Address2
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Company
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing City
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Zip
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Province
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Country
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Billing Phone
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Shipping Name
[/TD]
[TD]recipient_name
[/TD]
[/TR]
[TR]
[TD]Shipping Street
[/TD]
[TD]recipient_street1
[/TD]
[/TR]
[TR]
[TD]Shipping Address1
[/TD]
[TD]recipient_house_no
[/TD]
[/TR]
[TR]
[TD]Shipping Address2
[/TD]
[TD]recipient_street2
[/TD]
[/TR]
[TR]
[TD]Shipping Company
[/TD]
[TD]recipient_name2
[/TD]
[/TR]
[TR]
[TD]Shipping City
[/TD]
[TD]recipient_city
[/TD]
[/TR]
[TR]
[TD]Shipping Zip
[/TD]
[TD]recipient_zip
[/TD]
[/TR]
[TR]
[TD]Shipping Province
[/TD]
[TD]recipient_state
[/TD]
[/TR]
[TR]
[TD]Shipping Country
[/TD]
[TD]recipient_country
[/TD]
[/TR]
[TR]
[TD]Shipping Phone
[/TD]
[TD]recipient_phone
[/TD]
[/TR]
[TR]
[TD]Notes
[/TD]
[TD]recipient_comment
[/TD]
[/TR]
[TR]
[TD]Note Attributes
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Cancelled at
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Payment Method
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Payment Reference
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Refunded Amount
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Vendor
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Id
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tags
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Risk Level
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Source
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Lineitem discount
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 1 Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 1 Value
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 2 Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 2 Value
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 3 Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 3 Value
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 4 Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 4 Value
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 5 Name
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Tax 5 Value
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Phone
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]recipient_language_code
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]recipient_fax
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]recipient_type
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,828
Messages
6,181,215
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top