CSV Import with custom Identity Part Separator in RavenDb - csv

I'm preparing a csv file to be imported into RavenDb, and have a column named Raven-Entity-Name to specify into which collection the documents have to be imported.
This data will be used by an ASP.NET MVC app, and so that RavenDb's default identity part separator (/) doesn't wreck havoc with my routes, I define a custom one on my app's start-up:
DocumentStore.Conventions.IdentityPartsSeparator = "-";
The csv import actually generates id's using the default separator, is there a way I can specify a custom IdentityPartsSeparator when importing a csv file or is manually generating the id's on the csv file the only option?

No, there isn't. You need to load the csv file using your code to control that.

Related

Groovy: Read CSV File without using external library, put column into array

My CSV file:
Created Date,User Name,Email Address,First Name,Last Name
?20-05-2020,Test1,test1#abc.con,Test,1
20-05-2020,test2,test2#abc.com,Test,2
20-05-2020,Test3,test3#abc.com,Test,3
I want to get all the email address and put it in Array + Without using external reference/ Library.
Please help.
Not using a library is a recipe for disaster. There will almost end up being entries that contain commas or whatever the actual separator is, and Excel is notorious for creating corrupted CSVs (non-standard is what it Excels at)
The beauty of Groovy scripts is that they are standalone files that can reach out to the world without requiring any other infrastructure except Groovy being installed.
Using Grape, you can automatically indicate that you want to use a 3rd party library and not worry about jar files, classpaths or installing dependencies.
#Grab(group='org.apache.commons', module='commons-csv', version='1.8')
Now you can import the relevant CSV classes you want and just use them.
This will help you parse the csv without a library:
new File("src/data.csv").splitEachLine(",") { line ->
println "CreatedDate: ${line[0]}; UserName: ${line[1]}"
}
For adding the values to a List, you can do it in the normal way inside the closure.

JMeter read the second sheet of CSV

How can I make JMeter read the second sheet of my CSV?
I want to use CSV Data Set Config.
Normally, it reads the first line of the first sheet but is there any way to be a bit more flexible?
CSV file format doesn't have "sheets", it is a normal plain text file using delimiters in order to represent structured data.
If you are trying to get data from i.e. Microsoft Excel file type - unfortunately you won't be able to do it using CSV Data Set Config. The easiest would be exporting data as separate plain-text CSV files.
If you don't have the possibility to do the export you still can access the data from Excel files but it will be a little bit more tricky as you will have to use JSR223 Test Elements, Groovy language and Apache POI libraries
More information:
Busy Developers' Guide to HSSF and XSSF Features
How to Extract Data From Files With JMeter
Currently you can use CSV Data Set Config for that, you should add external code for example using Apache Commons CSV,
Download the jar file and place it in JMETER_HOME lib folder, and then write the code in JSR223 Element.
Examples exists, code for get second record:
Reader in = new FileReader("path/to/file.csv");
Iterable<CSVRecord> records = CSVFormat.RFC4180.parse(in);
// go to next record
records.next();
CSVRecord secondRecord = records.next();
//columnOne = secondRecord.get(0);

I get a mysterious "Neo.ClientError.Statement.InvalidSyntax" error when loading a CSV in Neo4j

For a course on Excel I was trying to load a CSV in Neo4j (first time using this application) when I was blocked at the first step of replicating an example shown in said course: loading.
The command which was used in the example was this;
LOAD CSV WITH HEADERS FROM "file:/path/to/file/file.csv"
as row
CREATE (m:movie {name:row.movie})
But it gave syntax errors. I found out I could correct it by using double \ and add "file:";
LOAD CSV WITH HEADERS FROM "file://C:\\path\\to\\file\\file.csv"
as row
CREATE (m:movie {name:row.movie})
Neo4j accepts this syntax, processes for a few moments, and returns YET ANOTHER error;
Neo.TransientError.Statement.ExternalResourceFailure
I tried the same commands (original and my own) in the online Neo4j console but no luck. I can reach the file using that path without problem; it really is there. The CSV file consist out of just 5 strings of regular letters, that's all. No fancy formatting or characters.
What's going on?
Not that mysterious, Neo4j's IMPORT CSV function looks for the specified CSV file in the import directory within your server configuration for that database, as specified at the top of its server configuration file. (IE: dbms.directories.import=import in your neo4j.conf file.)
You should create the import directory in...
"C:\Users\[User Name]\Documents\Neo4j\default.graphdb\"
If you place your CSV file in there, you can specify any sub-directory or just the "file.csv" you want to import with the IMPORT CSV function as below.
LOAD CSV WITH HEADERS FROM "file:///file.csv"
AS row
RETURN row
LIMIT 5
Try using:
"file:///C:/path/to/file/file.csv"
Since your file is on your local computer, the third / following the file scheme is not preceded by a host name or address -- but it still needs to be there. Also, file URI path separators should be forward slashes (even on Windows machines).
See the File URI scheme Wikipedia page if you need more information.

Import csv with paths to pdf files

I have a custom content type (product) containing a title, some text and a file (a pdf file).
A lot of products have to be imported to the Drupal CMS. I discovered the plugin "Feeds" which seems to fulfill my requirements.
I managed to import a csv files containing a title and some text.
Now in my csv file I have a column containing a path to all the pdf files (like C:\mypdfs\product1.pdf). How can I manage that those pdf files are imported by Feeds? In "Mapping" configuration I'm not sure what target I have to select for those column which contains the path to a local file.
Using Feeds Tamper module you can manipulate the value of imported data for one target. Here you can build a custom tamper (See How) and use it to process the retrieved value (file path), using file_get_contents to get the file from imported path and file_save_data to save a file in Drupal, getting a field object that you can attach to an entity (this could help).

Issues with Access parsing double quotes in a CSV file

I have a large CSV file that I am trying to import into Microsoft Access but I am running into issues. Assume pipes represent different cells in the database
Assume my content is the below. The second entry will only parse the word my with default settings and will not import the word content into the database even though the import wizard implies that it will. The default settings being , delimiter and " text qualifier.
|my content is good|
|my|
Now if i change the text qualifier to NONE it parses the entire second entry and my content will be imported into the database however the first entry will wind up being in 3 different cells in the data base and will show up as
my|content|is|good.
|my content
I used pipes to imply different cells.
This seems like a limitation in Microsoft Access. Is anyone familiar with a workaround for this?
Original content:
,"my,content,is,good","",
,my"content","",
I am using the import wizard
Yes, this is a limitation of the CSV import capabilities in Access. For whatever reason, Access has always been more restrictive than Excel in its abilities to parse CSV files.
So, one workaround would be to open the CSV file in Excel, save the file as an actual Excel sheet, and then import the Excel sheet into Access. For example, the CSV file
this,is,a "test",CSV file,"Ugly, yes, but still parsable."
is "non-standard" (if one is willing to concede that there is such a thing as a CSV "standard"), and Access cannot import it directly. (It either complains of an "Unparsable Record" or it splits the last field on the commas, depending on the "Text Qualifier" setting.)
However, we can open it in Excel
save the file as "foo.xlsx", and then import the .xlsx file into Access