Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 877
  • Last Modified:

How to Automate CSV file manipulation?

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
plug1
Asked:
plug1
  • 4
  • 3
  • 2
  • +1
2 Solutions
 
Mike LazarusAct! Evangelist - CRM ConsultantCommented:
0
 
Mike LazarusAct! Evangelist - CRM ConsultantCommented:
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
 
plug1Author Commented:
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 Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
aikimarkCommented:
@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
 
RobSampsonCommented:
If you show us a sample before and after copy of the CSV, we could help you rearrange it with a script.

Rob.
0
 
plug1Author Commented:
Rob, that's the best thing Ive ever heard :) ... I'll be back later!
0
 
RobSampsonCommented:
Lol.... I don't know about "ever", but samples would certainly help us help you.
0
 
plug1Author Commented:
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
 
plug1Author Commented:
Cheers people.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Simple Misconfiguration =Network Vulnerability

In this technical webinar, AlgoSec will present several examples of common misconfigurations; including a basic device change, business application connectivity changes, and data center migrations. Learn best practices to protect your business from attack.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now