Solved

Csv files date

Posted on 2016-10-03
4
46 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 42

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 42

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 42

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

820 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