I have bulk of data in an Excel sheet and I saved it into .csv format like this:
101,shortname,null,Description
My question is how to place single quotes for text data like
101,'shortname',null,'description'
?
101,shortname,null,Description
1) Is this in the single cell or different cells in excel?
2) Do you want to update the excel sheet or just want to put that data in mysql?
If you want to take data from excel and put it into mysql you can use apache-poi libraries.
apache-poi
I used this library to update the excel sheet from mysql database.
Get an editor capable of doing search/replace with regular expressions
Write a regular expression that will update the text the way you want it to
Here's an example how to do what you ask in Visual Studio's text editor:
Find what:
{[^,]+},{[^,]+},{[^,]+},{[^,]+}
Replace with:
\1,'\2',\3,'\4'
If you have some other editor, go check its documentation on regular expressions.
For VIM check out vimregex.com, something like this might work:
s:\([^,]\+\),\([^,]\+\),\([^,]\+\),\([^,]\+\):\1,'\2',\3,'\4':
so you want your csv data to add a single quote and restore in the same file? I this is so, simply copy/cut that column in some other column and use an excel formula like suppose you have your shortname in column B cut-paste it to column Z and use formula =CONCATENATE("'",Z#,"'") # is the row number
Related
This is perhaps one of those many times discussed questions with solutions more specific to actual system that outputs the data into a CSV file.
Is there a simple way to export data like 3332401187555, 9992401187000 into a CSV file in a way that later when opened in Excel, the columns won't show them in "scientific" format? Should this be important, the data is retrieved directly by an SQL SELECT statement from any DBMS.
This also means that I've tried solutions like surrounding the values with apostrophes '3332401187555' and the Excel cell recognizes those as text and doesn't do any conversions/masking. Was wondering if there was a more elegant way without actually it being a pre-set Excel template with text data fields.
1. Try exporting the numbers prefixed with single quote. Example: '3332401187555.
2. In excel, select the column containing number values
and then select Number in Format Cells.
Just have to save your file with Excel the option CSV file. And you have the in file in requested format.
I have my SQL output as five columns. When I paste the SQL output to Excel it seems to concatenate everything that is a string into one column until a number appears.
In this case, my first 4 columns are text and Excel they are concatenated to one column. My fifth column is a number and that's in the 2nd column in Excel. My column headers are all concatenated to a single cell.
When I paste to NotePad it looks fine. And even when I paste to a text box inside of Excel it looks fine. But when I go to paste the data from NotePad and the text box I get the same thing.
Does anyone know a solution for this? And is this an Excel or SQL issue?
Somehow the Text to Columns in my Excel settings got switched to comma instead of tab. Go to Data > Text to Columns > choose delimited and then choose tab.
I have a PowerPivot opened in Excel that's loading a csv file.
I need to remove duplicates in a column but there is no query edit.
What's the best way to do this?
The column in question contains text values like addresses
There are two options, you can use power query (part of excel 2016, addonn in excel 2013) to clean the data up before it is loaded into power pivot. Note that if you are using power query it is case sensitive so it will consider ABC <> Abc.
It does have functions to force strings to be all upper case, lower case or Capital for the first word.
The option is to setup the connection in Power Pivot, then go to the loaded table in the model. In the ribbon do design --> Table properties which has options for editing the SQL statement which is used to generate the table.
I have an excel marco script to generate db data to do comparison, I found that excel cannot display whole Long data type content that return from sql statement (only return few letter).
How can I write the sql so that excel can display all contenet in Long data type?
Thanks!!
Please take a look here at the limitations of Excel
If it is a possability for you, I would try to select your data into several columns
Select left(string, Len(string)/2), right(string, Len(string)/2) from table
You may take a look at refernce for this here
You may also insert an if clause to only split if its over a specific value (e.g. the Excel cell max)
I've noticed that if I use the text-to-columns feature with comma as the delimiter, any comma-delimited data I paste into Excel after that will be automatically split into columns.
This makes me think Excel must have some kind of global delimiter.
If this is true, how would I set this global delimiter using Excel VBA? Is it possible to do this directly, or do I need to "trick" Excel by doing a text-to-columns on some junk data, then delete the data?
My ultimate goal is to be able to paste in a bunch of data from different files using a macro, and have Excel automatically split it into columns according to the delimiter I set.
Junk data is the right answer. See here
http://spreadsheetpage.com/index.php/tip/clearing_the_text_to_columns_parameters