I am using Excel for Mac 2016 on macOS Sierra software. Although I have been successfully copying and pasting CSV files into excel for some time now, recently, they have begun to behave in an odd way. When I paste the data, the content of each row seems to split over many columns. Where as before one cell would have been able to contain many words, it seems now as though each cell is only able to contain one word, so it splits the content of what would normally be in one cell, over many cells, making some rows of data spread out over up to 100 columns!
I have tried Data tab>> From text>> which takes me through a Text Wizard. There I choose Delimited>> Choose Delimiters: Untick the 'Space' box ('Tab' box is still ticked)>> Column data as 'General'>> Finish. Following this process appears to import the data into its correct columns. It works. BUT, a lot of work to get there!
Question: Is there any way to change the default settings of Delimiters, so that the 'Space' delimiter does not automatically divide the data?
I found an answer! It has to do with the "Text to Columns" function:
The way fix this behavior is:
Select a non-empty cell
Do Data -> Text to Columns
Make sure to choose Delimited
Click Next >
Enable the Tab delimiter, disable all the others
Clear Treat consecutive delimiters as one
Click Cancel
Now try pasting your data again
I did the opposite regarding "consecutive delimiters"!
I put a tick in the box next to "Treat consecutive delimiters as one", and THEN it worked.
Choose delimiter directly in CSV file to open in Excel
For Excel to be able to read a CSV file with a field separator used in a given CSV file, you can specify the separator directly in that file. For this, open your file in any text editor, say Notepad, and type the below string before any other data:
To separate values with comma: sep=,
To separate values with semicolon: sep=;
To separate values with a pipe: sep=|
In a similar fashion, you can use any other character for the delimiter - just type the character after the equality sign.
For example, to correctly open a semicolon delimited CSV in Excel, we explicitly indicate that the field separator is a semicolon:
reference
Related
I'm trying to export data from KDB to a csv file. Unfortunately, when I do this, the leading zeros disappear. For example, 0355 becomes 355.
Is there a hack of sorts that I can use to get around this issue?
I think your issue may be in the process of opening the CSV with excel. The prevailing 0's are still present until viewed in excel.
If you are wanting to view the data in excel one option would be to first string the data and then add a prevailing ' in kdb. For example:
q)table: flip `a`b`c!(`001`002`003; 123; 10 12 12)
q)update a:("'",'string a) from table
a b c
-------------
"'001" 123 10
"'002" 123 12
"'003" 123 12
This effectively acts as a indicator stating "this is text", thus the 0 will be retained. The ' will not be visible in the cells unless you edit a specific cell, as a result it is useful for displaying these symbols. Other than this I think your best option would be to just change the column type settings in excel.
If your .csv file contains the leading 0's when opened in notepad, then the problem is likely that Excel is misinterpreting the value as a number since when kdb+ exports symbols to a csv file it does without wrapping the value in quotation marks.
To get around this open Excel and click on the 'Data' ribbon and then 'From Text' to import your csv using the Import Wizard. Once you have selected your csv, the wizard will open and you can set the delimeter as comma.
You will then be able to choose the data types for each column, and setting the column with the leading 0's as text format will make them appear correctly.
I want to export a huge excel file as a .csv, but the data contains commas within the cells.
How do I export the excel data to a .csv with the deliminator as this |
I've tried doing the usual "save as", but it is not working for my data.
Hi Check out this method in the below link, its what I have used in the past
https://www.howtogeek.com/howto/21456/export-or-save-excel-files-with-pipe-or-other-delimiters-instead-of-commas/
Summary:
Control Panel –> Region and Language, and then click the Additional settings
When in the additional settings find “List separator”
Change this to anything you want, in your case you would want the | pipe
By definition CSV stands for Comma Delimited.
Easy alternatives that were under your nose in the Save As window are:
"Formatted Text(Space Delimited)" though this won't be appropriate if you have spaces in your cells
"Text(Tab Delimited)" it is less likely you'll have tabs in your cells and people won't type those in to excel.
If you really want the 'pipe' | then I would suggest saving as tab delimited and running some kind of find & replace on the resulting text file. This is a bit of a workaround
A even bigger workaround is to concatenate the cells using a formula on the sheet with a | involved and the save as text only that column.
I have a lot of data in the form of
"00:00:03:19"
(hh:mm:ss:milliseconds)
I can not do much with it since excel is interpreting the data as text. Under "format cells/custom"
I can not find an appropriate entry for the data.... How can I teach/show excel what kind of data I am processing there?
I'm afraid the only option for Excel to read that properly is to somehow replace the last colon : with a decimal point. It's not until Excel understood your data as expected that you can think of the appropriate display format.
How are you receiving this data? If you can have all these values aligned in a single column in a csv file for example, by using a good text editor like Notepad++ you could select all the last : with ALT + mouse, replace them all at once, and finally load that into Excel.
One option is:
=SUBSTITUTE(A1,":",".",3)
select, Copy, Paste Special, Values then Text to Columns with Tab as the delimiter.
I found another solution!
I pasted the timevalues into the A column and split it via the LEFT,MID RIGHT comands
(eg:00:00:01:21 in A3)
A---------------------B-----------------C----------------D---------------E-----------------------F--------
00:00:01:21 -- LEFT(A3;2) -- MID(A3;4;2) -- MID(A3;7;2) -- (RIGHT(A3;2)) -- E3+(D3*1000)+(C3*60000)+(B3*3600000)
I'm trying to select multiple values based on a search key. In it's most basic form there is no problem with this. I followed this example and everything went well:
http://office.microsoft.com/en-us/excel-help/how-to-look-up-a-value-in-a-list-and-return-multiple-corresponding-values-HA001226038.aspx
=IF(ISERROR(INDEX($A$1:$B$7,SMALL(IF($A$1:$A$7=$A$10,ROW($A$1:$A$7)),ROW(1:1)),2)),"",INDEX($A$1:$B$7,SMALL(IF($A$1:$A$7=$A$10,ROW($A$1:$A$7)),ROW(1:1)),2))
The problem with this however is that in my case I have multiple CSV files (external) where some values in my A$ column look like this:
=- sometext // results into #NAME? error
Excel interprets these as a formulas where it is actually only supposed to be a string. Sure I could change it to text and save it again but I would like to avoid any manipulation in these CSV files.
I tried to extend the second IF statement (if you read it from left to right) with:
IF(AND($A$1:$A$7 <> "#NAME?", $A$1:$A$7=$A$10,ROW($A$1:$A$7)))
and
IF(AND(NOT(ISERROR($A$1:$A$7)), $A$1:$A$7=$A$10,ROW($A$1:$A$7)))
Both didn't work. (Sorry if I messed up some syntax and formula names, I'm using a different language version)
Here a small image of what's happening right now and how it should look:
On the right site you can see a list of values right next to Test1 which are missing on the left site due to the #NAME? error.
I would suggest opening the csv's files as text files. Selecting Comma as your delimiter and then select Text as your Column data format. This way, Excel will treat all your data as text and will not try to read =- sometext as a formula.
To do so, you would need to change your .csv files extension to .txt or anything else (even no file format).
Instead of "Opening" the CSV file, you can "Import" it. This will open the Text Import Wizard which will allow you to specify particular columns as Text. This is located in different areas in different versions of Excel. In Excel 2007, it is on the Data Tab / Get External Data / From Text. The example below demonstrates bringing in long numbers, but it should work just as well with your formula "lookalikes"
How do you get around the exponential conversion that takes place when inserting a value into a csv file. I have a process that creates a csv file and then starts entering rows into it. One of those fields inside a row inserts a value similar to this:
123,45,45,466,6656,23423,2455,234,2454
These are just a string of id's i need to preserve on the csv file in order to import them into another program that expects a comma separated number of values in this field.
Of course when i open excel and look at this csv it gives me something like this:
123,45,45,466,6656,000,000,000,000
so those last few values mean nothing to the import process and it fails.
My question is how do i write to a csv file and get around my values being converted to exponential numbers as well as preserving the comma separated number values like above?
Thanks in advance
Billy
Put quotes around them
"123","45","45","466","6656","23423","2455","234","2454"
In order to get around this issue i used the following steps in MS Excel 2007:
Open a Blank Workbook in Excel.
Choose Data, Get External Data, Import Data. (Excel 2007 is Data, Get External Data, Data from Text)
Browse to your .csv file and Select "Import".
Import Wizard should appear.
Page 1 Select "Delimited"
Select the row which you want to start the import.
click "Next"
In the Delimiters, select "comma" and/or other delimiters you are using.
Note: The bottom half of the window will preview the way the data is to be imported.
click "Next"
highlight each column of your data in the window below. For each column you can specify "General", "Text", "Data", or "do not import column" using the radio buttons in the top left of the Wizard box. I used the "Text" option. This is an optional step.
Click Finish.
place the value in single quotes while using data
Eg:
String[] abc = {"0123455677888", "154758768969", "abcsdhfsdj", ""abcsdhfsdj3725423", "62343664268abcsdhfsdj"};
CSVWriter csvWriter = new CSVWriter(String fileName);
//csvWriter.writeNext(String[] stringArray)
csvWriter.writeNext(" \' "+abc[0]+" \' ", " \' "+abc[1]+" \' ", abc[2], abc[3], abc[4]);
Try this
It will store the data perfectly