Solved

How to Automate CSV file manipulation?

Posted on 2014-02-24
11
496 Views
Last Modified: 2014-03-04
I have a customer who uploads files to their system using CSV files which they are send from certain suppliers. The system rejects them if they are in the wrong format and they now have a new supplier sending their own style of CSV output. What I need to find out is how I can automatically parse the CSV file and copy the correct columns from their CSV into   the right columns on the new CSV. The new CSV file they recieve has all the data needed but just in the wrong places.

I think a macro of some sort would do this in Excel but I know very little about them?

Any ideas.. this must be a fairly simple thing to do (I Hope)

Thanks in advance
0
Comment
Question by:plug1
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 30

Assisted Solution

by:Mike Lazarus
Mike Lazarus earned 250 total points
Comment Utility
0
 
LVL 30

Expert Comment

by:Mike Lazarus
Comment Utility
Depending on the specific changes you need, there might be better options using VBScript or Powershell ...

You'll need to be careful if data includes fields for: currency, dates, phone numbers
0
 
LVL 14

Author Comment

by:plug1
Comment Utility
Its really just moving columns around and deleting ones which arent used? The tutorial you posted seems to be what I need.. just need to try it now.
0
 
LVL 30

Expert Comment

by:Mike Lazarus
Comment Utility
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
@plug1

The usual approach to this is to 'map' the CSV columns into their destination columns/fields.

If this is going to happen for more than one source, then create a source (database, flat file, workbook, etc.) that you can easily edit and that a VBA routine can easily read.  You can do this specification with column names, if present, or with column numbers.  This way, you won't have to change your code.

Another useful tool is Powershell.  Do you know anything about Powershell?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
Comment Utility
If you show us a sample before and after copy of the CSV, we could help you rearrange it with a script.

Rob.
0
 
LVL 14

Author Comment

by:plug1
Comment Utility
Rob, that's the best thing Ive ever heard :) ... I'll be back later!
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Lol.... I don't know about "ever", but samples would certainly help us help you.
0
 
LVL 14

Author Comment

by:plug1
Comment Utility
This has been resolved by the company supplying the original CSV in the correct format so unfortunately I cant try the first answer properly or take you up on your offer Rob, I'll split the points with you 2 though. Thanks alot.
0
 
LVL 14

Author Closing Comment

by:plug1
Comment Utility
Cheers people.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now