Solved

Csv files date

Posted on 2016-10-03
4
35 Views
Last Modified: 2016-11-06
I want to collect the dates of each filename.  I am getting all the data of each filename except the dates.  The date can come from filenames like the building number.  The building in the filenames are being stored with the other data except the dates.  The filenames, for example, looks like this 100_2016-10-3_10-31.  The first three numbers are the building numbers, the date, and _10-31 is the time. How can I get the dates stored as well?
C--Users-campbme-Documents-CSV-file.docx
0
Comment
Question by:campbme
  • 3
4 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points (awarded by participants)
ID: 41826864
Dirty way:

You may simply update the following command in your code:

DO ImportFile WITH m.lcPath, laFiles[m.lnI, 1]

to

lcDateStr = CHRTRAN(STREXTRACT(laFiles[m.lnI, 1], '_', '_'), '-', ',')
DO ImportFile WITH m.lcPath, laFiles[m.lnI, 1], DATE(&lcDateStr))  && Remember you are sending the Date data type here

lcDateStr should be declared as LOCAL in the declaration part on top.

Cleaner way would be to parse the date from the file name without the & macro substitution, e.g.

*-- Four digits year is expected
lcDateStr = STREXTRACT(laFiles[m.lnI, 1], '_', '_')
ldFileDate = DATE(VAL(m.lcDateStr), VAL(SUBSTR(m.lcDateStr, 6)), VAL(SUBSTR(m.lcDateStr, AT('-', m.lcDateStr, 2)+1)))
DO ImportFile WITH m.lcPath, laFiles[m.lnI, 1], m.ldFileDate

Additional ways exist...
0
 
LVL 41

Expert Comment

by:pcelba
ID: 41847230
campbme, did you try this solution? It must work because I've tested in on my own data.

If you are not sure what to do then simply place  SET STEP ON  at the beginning of the code and it will open debugger where you can investigate values of your variables in each line and go through your code step by step.

Of course I can offer more help but you have to respond to the posts.
0
 
LVL 41

Expert Comment

by:pcelba
ID: 41875977
Unfortunately, the question author did not respond but I know my answer works well because it was tested in VFP9.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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,…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

867 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

21 Experts available now in Live!

Get 1:1 Help Now