+ Reply to Thread
Results 1 to 12 of 12

Creating a database of sales, whereas each daily sale is a separate CSV file

  1. #1
    Registered User
    Join Date
    03-23-2017
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    9

    Creating a database of sales, whereas each daily sale is a separate CSV file

    Hello,
    what I have are 690 CSV files with seven columns and where each line contains data for a summary of all sales regarding one product (beers and liquors, to be specific). Each one file contains data from one day, and is named in a dd/mm/yyyy format.

    what I want is to create a database that will contain data from these CSV files, where I'll be able to easily find monthly/weekly sales summaries, make up some statistics.

    Where to start, then? Batch processing is a must when dealing with over half a thousand files. I attach data from five consecutive days.
    Best regards,
    Michael
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    The data in the CSV files is in a funny format. I had to add some columns and do a piecemeal text-to-columns on the data before importing them.

    The report takes data from a To Do directory, this is where the CSV files get collected originally, and it moves them to a Done directory.

    Both of these directories are subdirectories of the same root directory.

    You tell the program where you want the root directory to be in cell B2 on the control panel sheet. Then provide the names of the To Do and Done directories in cells B3 and B4.

    The program looks at each CSV file in the To Do directory, puts the data on the data sheet and then moves the CSV file to the Done directory.

    Do you need to parse out the date from the CSV file name and add it to the data?
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    03-23-2017
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    9

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    Thank you very much for your reply, I've followed the instructions carefully.

    Here's what I've got.
    It appears that the script doesn't 'see' the .csv files. I've attached the screenshots. And yes, I will need to parse the date right from the filename.

    best regards ;]
    Attached Images Attached Images

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    In cells B3 and 4, don't include the "X:\Dropbox\T4_Praca magistrerska\Copy CCS" - this part is added to the path by the code. Just use "To Do" and "Done." You can change these names to their Polish equivalents as long as you do it in the directory structure and in these two cells.

    I'll work on parsing out the date from the file names and get you a version that does this most likely later today.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    This turned out to be easier than I thought.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-23-2017
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    9

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    The script works wonderfully and after putting the data into a pivot table I can work miracles. But before we begin with that, there's one more problem to solve: within exactly 190 CSV files there's a value in 'nazwa' (product name) column that contains a comma, so when the scripts reads that value it splits the name into two values in two different columns, thoroughly messing up the final data structure. Either we have to change the values in original CSV's with some grep-like utility or teach the script to skip commas in 'nazwa' column. I will be grateful for any help. ; ]

    I've got my hands on another 690 CSV files I've got to assemble but this kind is a little bit trickier. What has to be done during assembling is:
    - skip rows 2 and 3
    - retain original data format (percentage, decimals separated with comma OR commas changed into dots, negative values)
    - and finally create a 'data' column with filename parsed into a date format, just like before

    I attach sample data and screens of that comma issue.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Chimney343; 04-01-2017 at 01:16 PM.

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    I don't think I can help you with this issue. Excel expects the CSV file to use the comma as a delimiter, so when it opens it, it opens it into columns sorted by the delimiter. I can see several ways around this.

    One is to scrub the data using another utility such as grep or awk (old Unix man here). Put it into a PERL shell to produce a clean CSV file.

    Another is to rename the CSV files with a *.txt extension. Open them, loop through a table of exceptions that you maintain manually, make the substitutions, save the files. rename the file sback to CSV, then open them again and *then* start the program I've already provided.

    Or get a cleaner source of data. I am not quite sure what the designer of this system had in mind with this output.

  8. #8
    Registered User
    Join Date
    03-23-2017
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    9

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    As far as I am concerned, the system designer didn't really put much thought into exporting data, hence all these problems. A macro that opens a CSV and replaces commas into dots should do the trick, as it's the only issue currently.

    Could you please take a look into reports I added in my last post? ; ) The ones where the script has to skip rows 2 and 3.

  9. #9
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    I am looking into that now.

    I have another question. If I replace all the commas with dots and then separate the data into columns based on semicolons, would that give me the correct data? I might have a different plan of attack if this is the case.

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    Does this look correct?
    Attached Images Attached Images

  11. #11
    Registered User
    Join Date
    03-23-2017
    Location
    Poland
    MS-Off Ver
    2010
    Posts
    9

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    Yes, it is correct. Semicolons never appear in cells as part of a given value, so separating data based on semicolons will work. Actually commas, dots and percentage symbols are the only special characters that appear in any type of report.

  12. #12
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating a database of sales, whereas each daily sale is a separate CSV file

    In that case, I have a different way of doing this. I'll respond in the other thread since it has some additional requirements.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to create a daily sales tracker file when figures are altered every day?
    By sajithnair in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2014, 02:52 PM
  2. Creating a database from daily production reports
    By FroukeWiersma in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2013, 05:43 AM
  3. Replies: 2
    Last Post: 10-17-2013, 11:52 AM
  4. Need Help creating an Excel Sheet for Daily sales
    By lala0517 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-09-2013, 12:44 PM
  5. Replies: 3
    Last Post: 06-04-2013, 02:56 AM
  6. creating a yearly database file using info in daily file
    By bilbobagginz in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-12-2008, 09:47 AM
  7. Creating an Excel Database in Separate Workbook
    By Brian C in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-16-2006, 06:25 PM
  8. Creating a Dynamic Inventory List Based on Daily Sales
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-29-2005, 11:01 AM

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