Results 1 to 2 of 2

Loading and reformating CSV file in excel worksheet

Threaded View

  1. #1
    Registered User
    Join Date
    10-22-2013
    Location
    Spain
    MS-Off Ver
    Excel 2007
    Posts
    2

    Loading and reformating CSV file in excel worksheet

    Hi,

    I am newbie in Excel and VBA programming. I want to import CSV data from a file into Excel, but I am facing a problem when reformatting it. It is as follows:

    In the CSV file I have the data as follows:

    date, variable1, itsvalue
    date, variable2, itsvalue
    date, variable3, itsvalue
    date1, variable1, itsvalue
    date1, variable2, itsvalue
    date1, variable3, itsvalue
    date2, variable1, itsvalue
    date2, variable2, itsvalue
    date2, variable3, itsvalue
    ...
    date_n, variable1, itsvalue
    date_n, variable2, itsvalue
    date_n, variable3, itsvalue

    I dont know how many variables I will have. Maybe 3, or maybe 20. But, provided a specific csv file, I will have the same number of variables for each date. I want to load the data and reformat them in an excel worksheet file as follows:

    DATE VARIABLE1 VARIABLE2 VARIABLE3 ... VARIABLE N
    date1 value1 value2 value3 ... value n
    date2 value1 value2 value3 ... value n
    date3 value1 value2 value3 ... value_n
    date4 value1 value2 value3 ... value_n
    ... value1 value2 value3 ... value_n
    date_n

    I,e, I want to have one column per variable and its corresponding value for a date (date is in the format year-month-day-hour-min-seconds, e.g. 20131023104520, which corresponds to year 2013 month 10 day 23 and hour 10 min 45 seconds 20.

    Since in the csv file I get the variables in a fixed period (e.g. each 10 seconds, so the date woould change each 10 seconds). This is my approach:
    counter = 0
    1. Read the seconds of the date
    2. If ther seconds are equal to the seconds of the next wor increase a counter.
    3. If seconds are different in the next row --> stop increasing the counter. The counter is now equal to the number of variables, and then I have a defined a block (number of variables recorded for a specific date, which will be always the same)
    date1, variable1, itsvalue
    date1, variable2, itsvalue
    date1, variable3, itsvalue

    4. With the aforementioned defined block, I think I could the formating I want in the worksheet.

    Could someone point me out a way to do this? I need somehow first to get the number of variables and then to create the table in the worksheet.

    Best regards,

    -E
    Last edited by ethanzur; 10-23-2013 at 09:45 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel asks me to update values by loading new file
    By Jonathan9 in forum Excel General
    Replies: 1
    Last Post: 09-23-2013, 01:10 PM
  2. Excel Stopped Loading Worksheet!!!!
    By Steveo555 in forum Excel General
    Replies: 1
    Last Post: 05-08-2012, 08:27 AM
  3. Loading online image into Excel file without VBA
    By archer09 in forum Excel General
    Replies: 0
    Last Post: 03-13-2012, 11:35 AM
  4. Replies: 3
    Last Post: 11-28-2010, 07:54 AM
  5. Loading from another excel file
    By KcA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2008, 03:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1