Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Automate CSV file manipulation?

Posted on 2014-02-24
11
Medium Priority
?
726 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 1000 total points
ID: 39885003
0
 
LVL 30

Expert Comment

by:Mike Lazarus
ID: 39885052
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
ID: 39885057
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 46

Expert Comment

by:aikimark
ID: 39885885
@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
 
LVL 65

Accepted Solution

by:
RobSampson earned 1000 total points
ID: 39893569
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
ID: 39894024
Rob, that's the best thing Ive ever heard :) ... I'll be back later!
0
 
LVL 65

Expert Comment

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

Author Comment

by:plug1
ID: 39905632
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
ID: 39905635
Cheers people.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

916 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