Solved

Csv files date

Posted on 2016-10-03
4
27 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)
Comment Utility
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
Comment Utility
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
Comment Utility
Unfortunately, the question author did not respond but I know my answer works well because it was tested in VFP9.
0

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.

Join & Write a Comment

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

762 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

6 Experts available now in Live!

Get 1:1 Help Now