Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-13-2021 01:55 PM
I have problem loading multiple files using a query, the issue is with parameter:
LOAD CSV WITH HEADERS
FROM 'https://raw.githubusercontent.com/moxious/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/$file' AS line
WITH coalesce(line.`Province/State`, 'General') as province,
coalesce(line.`Country/Region`, 'Missing') as region,
datetime(line.`Last Update`) as lastUpdate,
date(datetime({ epochMillis: apoc.date.parse(replace("$file", ".csv", ""), 'ms', 'MM-dd-yyyy') })) as reportDate,
toFloat(line.Latitude) as latitude,
toFloat(line.Longitude) as longitude,
line
09-13-2021 01:58 PM
@shaina.raza
cold you provide more details? what parameter and your code snippet in the original post may have been truncated and thus not showing the complete detail
09-14-2021 06:43 AM
Thanks @dana.canzano for the response.
So I am running the following piece of code in the Neo4j Desktop and this is a cypher query that I am trying to run.
The query is taking a folder from the github and try to read the filename as a parameter. However, at my end, this is not running and gives me the error.
The code is :
//USING PERIODIC COMMIT
LOAD CSV WITH HEADERS
FROM 'https://raw.githubusercontent.com/moxious/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_rep...' AS line
WITH coalesce(line.
Province/State
, 'General') as province,coalesce(line.`Country/Region`, 'Missing') as region, datetime(line.`Last Update`) as lastUpdate, date(datetime({ epochMillis: apoc.date.parse(replace("$file", ".csv", ""), 'ms', 'MM-dd-yyyy') })) as reportDate, toFloat(line.Latitude) as latitude, toFloat(line.Longitude) as longitude, line
MERGE (p:Province { name: province })
MERGE (r:Region { name: region })
CREATE (s:Report {
label: region + ' ' + line.Confirmed + ' CONFIRMED ' + line.Deaths + ' Deaths ' + line.Recovered + ' Recovered', /* Critical distinction: reportDate is when the stat was reported, lastUpdate was when the province provided * the data. So for example, on March 2 2020, if the last update available from San Mateo, CA was on February 28th, * then lastUpdate=February 28, and reportDate=March 2 */ reportDate: reportDate, lastUpdate: lastUpdate, /* How far the province reporting is lagging. 3 means that the last stat we got was 3 days ago */ ageInDays: duration.between(lastUpdate, reportDate).days, confirmed: toInteger(coalesce(line.Confirmed, 0)), deaths: toInteger(coalesce(line.Deaths, 0)), recovered: toInteger(coalesce(line.Recovered, 0)), latitude: latitude, longitude: longitude, location: point({ latitude: latitude, longitude: longitude })
})
MERGE (p)-[:IN]->(r)
CREATE (p)-[:REPORTED]->(s)
RETURN count(s) as ReportsLoaded;
I get this error
when I read one file, it works, when I try to read via parameter, it does not work.
thanks
09-14-2021 07:38 AM
change
FROM 'https://raw.githubusercontent.com/moxious/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/$file' AS line
to
FROM 'https://raw.githubusercontent.com/moxious/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/' + $file AS line
All the sessions of the conference are now available online