Have what I thought was a simple problem, I'm not able to upload a CSV into Dialogflow's Knowledge due to the following error:
CSV documents must have exactly two columns. The provided document has 3 columns.
I realised quickly that for whatever reason Dialogflow didn't like the way I was escaping commas in each column. Consider the following example:
This is column 1\,line 1,This is column 2 line 1
Validates via CSV Lint so it should work, but doesn't. I've also tried escaping commas with double quotes, but still get the error.
Any ideas appreciated?!
To escape the comma's in a row of csv we have to put the string inside double quotes.
So correct way will be :
"This is column 1,line 1","This is column 2 line 1"
Thanks to #sid8491 for answering. The solution for Dialogflow is to escape every row in your CSV around quotes, even if you only have one column that uses a comma. So the example above is correct:
"This is column 1,line 1","This is column 2 line 1"
Related
I have numerous files where the address field is in a single line of text, for the most part separated by a comma. My first step is using 'Replace' function in Excel to replace comma's with a carriage return. This is to turn an address from a single line into multiple lines.
The issue I'm looking to get assistance with, is when I complete the steps above, a leading space is often remaining in all rows from the second row onwards. I would like to know the best way to remove the leading spaces in these rows and keep the format of multi-line addresses.
I have tried using TRIM however these returns the address back to a single line
To show the pre and post transformed data I've added an image below as I can't seem to get the format to show correctly here on this post. Due to my profile being new I also can't imbed the image so there is a link below showing the pre and post transformed data, and the leading space issue I'm seeking help with
Pre and Post Example
Thanks,
Steve
As #Anonymous mention in comment, replace both comma and space at a time by SUBSTITUTE() formula and use WRAP TEXT format of resulting cell.
=SUBSTITUTE(A2,", ",CHAR(10))
I am trying to parse a CSV file which has single quote as text qualifier. The problem here is that some values with single quote text qualifier itself contains single quote
e-g:
'Fri, 24 Feb 2017 17:44:57 +0700','th01ham000tthxs','/','','Writer's Tools Data','7.1.0.0',
I am struggling to parse the file as after this row, all of the remaining rows get displaced.
I tried working with OpenCSV, UnivocityParsers but didn't get any luck.
If I place the above row in excel (Excel Image) and provide text qualifier as single quote, it give correct result without any displacement of rows.
If using java, the JRecord library should handle the File.
How it works: if a field starts with a quote (e.g. ,') specifically look for ', or ''', or ''''', or ' etc (an odd number of quotes followed by either a comma or end-of-line marker). This approach breaks down if:
The embedded quote is the last character in a field i.e. 'Field with quote '',
White space between the quote and comma i.e. 'Field' , or , '
Here is the line in ReCsvEditor
Also in the ReCsvEditor when editing the file, if you select Generate >>> Java Code >>> ... it will generate Java/JRecord Code to read the file.
Disclaimer: I am the author of JRecord / ReCvEditor. Also the ReCsvEditor Generate function is new and needs more work
Try configuring univocity-parsers to handle the unescaped quote according to your scenario. 'Writer's Tools Data' has an unescaped quote. From your input, I can see you want to use STOP_AT_CLOSING_QUOTE as the strategy to work around these values.
Add this line to your code and it should work fine:
parserSettings.setUnescapedQuoteHandling(UnescapedQuoteHandling.STOP_AT_CLOSING_QUOTE);
Hope this helps.
Scenario: I have some rows with string of data in excel. The data is always on the same order ("columns") but the size of the data in each "column" varies. In the original strings, there can be one or multiple blank spaces between each piece of "column" data, and so far I used the trim function to reduce that to 1 blank space.
Objective: I am trying to somehow separate the data from the string in different columns, but inside each column data, there might also be spaces, for example I am trying to output this original:
James Smith code1 code2 10.5 09/23/1900AT PRESENT UUUB SJ SPECIAL 250AAA No No NoCORRECTED part1
to this with trim:
James Smith code1 code2 10.5 09/23/1900AT PRESENT UUUB SJ SPECIAL 250AAA No No NoCORRECTED part1
as this:
James Smith code1 code2 10.5 09/23/1900 AT PRESENT UUUB SJ SPECIAL 250AAA No No No CORRECTED part1
where each field is in its proper column.
Obs1: One of the problematic fields for me is the one that has the result "AT PRESENT", because there is a space in between, and there is no space between the "AT" and the last digit of the previous column.
Obs2: I also face similar problems in the first row (headers), which also can have more than 1 work per field.
Obs3: Here are two other string examples that appear in the dataset:
code1 03/15/1950TEAM-ALPHA h/s/s CERTIFIED3-3/1 third point 03/19/1944 -- --SR SR Prototype
code1 200000.00especial reduced Redone third part -- No
What I already tried: I have been trying the LEFT, RIGHT and MID functions, but since I cannot foresee how many letters will be in most of the fields, I found no proper way to do it. I also tried doing simple character substitution, but that does not solve the problem of the fields that are mistakenly merged. The first thing I tried was using "text to columns": here the result is also problematic, if I have spaces inside a field it gets divided, and if there is no space between fields, there will also be an error. I am tried to to this as dynamically as possible, to account for different data variants.
Question: Any suggestions or ideas on how to tackle this situation?
Have you tried Text to Columns on Data tab?
Set your original data type delimited and select the "Space" delimiter. Make sure you tick "Treat consecutive delimiters as one"
I am trying to split some data up but stuck! I have some data which comes out like the below:
USERNAME Full Name Department
USERNAME First Initial Surname Department
USERNAME Full Name Department
I have tried numerous items such as trim then can pull out words however some peoples full names are 3 words and most of them are 2 words so this kinda breaks it all.
I have also tried substituting the double spaces so it breaks it up like so
##USERNAME#######Full Name######Department###########
##USERNAME###First Initial Surname Department#
##USERNAME###########Full Name#####Department#####
But still unsure how I can pick up the words between the hashes.
Help really appreciated :)
If you have a text file with the raw data, separate the raw data using either of a TAB, a semi-colon, or a comma. Pick something you do not already have in your file. Semi-colon usually works for me.
Then, open it as a CSV (comma-separated values) file in Excel.
It will try to parse the file automatically. If it doesn't succeed, it will ask you what character you want to use as a separator.
You mentioned double spaces seperating your data, that's your ticket in.
Let's say you've got "USERNAME David Brossard DEPT" in Cell A2.
In B2, let's FIND the first double space:
=FIND(" ",A2)
In C2, let's FIND the second double space:
=FIND(" ",A2,B2+1)
In D2, we'll grab everything in between:
=MID(A2,B2+2,C2-(B2+2))
There you go!
Alternatively, you can write it all in one formula, in B2:
=MID(A2,FIND(" ",A2)+2,FIND(" ",A2,FIND(" ",A2)+1)-(FIND(" ",A2)+2))
I am using excel to generate comma separated values. I have a parser to parse the csv data and insert to database.
The issue I face is, the first field in my csv is not mandatory. When the first field is null, the generated csv has no comma BEFORE the second field and for the parser the second field becomes the first field.
When the first field is null, I expect the data to be like below.
,SECOND_FIELD, THIRD_FIELD
I have tried
putting a space in the first field. In this case I wil have to change my parser.
Putting a static header. Then the comma is coming as expected in the underlying rows when first field is null. Change in parser will be required.
Putting a comma in the first field, but this is put as ",". :-)
Can someone through some solutions or workarounds ?
Thanks
Quick workaround: Why don't you check how many values are present? If one is missing, asume it's the first one.
EDIT:
I've found this question that may help you. In a nutshell: apply any formatting to the range of cells you are using so Excel doesn't skip any of them when exporting. Also, I think that if you can swap the first column (optional) with any other one (required), it will work, too.