Merging csv data

Posted on 2012-08-21
Last Modified: 2012-08-23

I would really appreciate some help on the following:

Have two instruments that we download data from as a csv files.
- Refer attached input1.csv and input2.csv

We would like to merge these files into one using a macro.
- Refer attached Output.csv

The issues:

On input files
- Do not need data in rows 1 to 6
- Column headings (row 7) vary slightly for example REL.PRESSURE (input1) and SYS-P(input2)
- Location of columns can vary
- We will need to upload multiple csv files of the two file types, ie more than 2 files will need to be uploaded and merge into Output.csv file

Output file
- Data to be sorted into the columns with titles appearing on row 1 (the REL.PRESSURE (input1) and SYS-P(input2) would go into the SYS-P column)
- Each input file should be added at end of the previous file inputted

Hope this enough information.


Question by:ian_greig
    LVL 39

    Expert Comment

    Is it possible to use Access? Free runtime version will be enough if you don't need any changes in logic.

    Author Comment

    no sorry we don't have access
    LVL 39

    Expert Comment

    Test sample (open VBA with Alt+F11 at first and add possible column names to array).
    All csv files from in folder will be added to out file.

    Author Comment

    Excuse the delayed response that is really good solution thanks.. it works very well

    I'm going to accept your solution :) I just forgot to add more thing to do if its possible to include(copy) Out data into an excel form so we can then organise/filter the data

    see attached file..  Form

    basically would be great to run the macro from the form.xls and have the data copied into the Out worksheet
    LVL 39

    Accepted Solution

    Sorry, due to EE rules, it should be new question.
    You can use this answer and try modify code:
    write to excel cells

    Author Closing Comment

    thanks for the help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
    We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    760 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

    9 Experts available now in Live!

    Get 1:1 Help Now