Solved

Csv files date

Posted on 2016-10-03
4
55 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

617 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