I am trying to import an Excel 2007 spreadsheet into a staging table and I am encountering issues with some of the column types. Some of my columns have a combination of numeric and text values i.e. A column called Customer No can have numeric values such as 1234, 32432433, or text values i.e. A1000, ACC101TEXT. When I import my spreadsheet, the values with text in them are returning null whereas the numeric values are being imported properly. Moreover, the last row has a text description in this column that I need, however, after the import, this row value is null. Is there anything I can do to rectify the situation and import the spreadsheet as is? I've tried using data conversions from the data flow transformation, however, that is still not working. Please note, I cannot change or format the excel spreadsheet. Any help would be greatly appreciated.
You need to use the Advanced Editor to tell the excel source the column is a Unicode String, not a numeric. That is why alphanumeric fields are null.
Right-click on the Excel Source and choose advanced editor
Choose the fourth tab "Input and Output Properties"
Choose the column in question under the "Output Columns" and change the source to Unicode
That should fix your problem.
Related
long time viewer, first time poster.
The issue I am struggling with relates to how my timestamp data appears in excel once I've run my code in snowflake and exported it to CSV. Unfortunately at the moment I am required to double click on these timestamp cells, once in exported into excel, for the true format (how it appears in results in snowflake) to appear.
There is a manual workaround to amend once the data is in excel, however I am automating this report for a client and therefore it must be presented correctly for them prior to the export.
As it stands (see below) the timestamp begins with YYYY-MM-DD and I have been asked to flip this firstly, to begin with DD. I thought that given I need to reformat the current timestamp, I may as well set it up correctly so the timestamp perhaps comes out as text, within the csv export? (from what I have read in other forums if you convert to text it is displayed in excel exactly how it appears in snowflake).
image.png
As you can see, I continue to get the "Cant Parse" error. The example timestamp given, is row 1 of the 'QuoteDate' variable.
The second part of the issue (or really the primary part of the issue) is how the timestamp completely changes format when exported (CSV) to excel. In the screen shot below I have double clicked the first 3 rows, leaving row 4 selected in order to show you all the error - which is the formula bar displays the correct format but the cell itself does not.
image.png
I hope this all makes sense and would love any assistance on how to amend this timestamp issue to run the code correctly, and present my client with a properly formatted timestamp within their extract.
Thank you :)enter image description here
For changing format
SELECT to_char ( to_timestamp ('2019-01-02 09:36:22.507' , 'YYYY-MM-DD HH24:MI:SS.FF') , 'DD-MM-YYYY HH24:MI:SS.FF') AS TS
Timestamp/dates are stored as NUMBER in database, you need to convert in required format for correct display.
to_timestamp --> Converts an input expression into the corresponding timestamp. This expects the input to be in the format provided as second argument.
to_char --> Converts the input expression to a string format.
For preserving data format while converting from csv to excel check Saving to CSV in Excel loses regional date format
I'm using a .XLS template instead of .RTF.
The problem is, even when I format the excel field cell to Text, I'm still getting #NUM! in the output.
The template is considering the data as an exponential value because of the character "E" in between the numbers. The exact value to be displayed in output is "12E18157" but I get #NUM! no matter what I do.
Any suggestions?
I was not successful in trying to format the .xls template cell because no matter how we format the cell, the template is considering the value as exponential value so I have concatenated a space for that particular column in my query(XML Data Definition file) itself and it fixed the problem.
I have imported a csv file from MySQL, documenting part numbers and descriptions. Some of these part numbers have values like 1234567890987654321, which is then shortened by excel to 1.23e18. Problem is, I cannot query a part with this formatted data.
Now I cannot feasibly go through every cell as there are just over 28000 of them. I have converted the row to text however this does not change the data in the cell.
The closest thing I have to a solution is deleting the cells and then undo-ing, which gets the number in a textual format but then gives me a 'number in text field' error.
Also some parts have part numbers like 12E345 which is then changed to 1200000000000000000000000000000000000000000000- you get the picture.
Very annoying...
I would like a batch process to change all the values to text format, thanks in advance.
Instead of just opening the CSV in Excel, import it with Data -> External Sources -> From Text.
You will have to first pick basic things like "delimited" format, whether first row contains headers, separator etc.
In the third part of the "Text Import wizard", you can pick data type of each column - picking Text for your columns will probably solve the problem.
I'm getting some import errors when importing data from Excel in to Access.
I'm using the DoCmd.TransferSpreadsheet acImport, ... method to do the import.
The column of data that is failing contains a mixture of number-only entries and strings. It's the string entries that are failing to import.
Is there something I can do to the data in this column of the Excel spreadsheet to ensure it gets across to Access in its entirety?
While your Excel.Application code from your previous question is in there "counting rows" it could also inspect the cell for that column in the first data row. If it is numeric, your code could glue an apostrophe (') at the beginning to force it to be a label, and then save the Excel file. Then, when Access' TransferSpreadsheet method looks at the first row it will decide that the column is text, not numeric.
I found something approaching a workaround:
Sort your offending column in Excel so that your numerics appear as the top-most group and your alphanumerics are at the bottom.
Highlight all your numerics now grouped in the column
Go to Data > Text to Columns
Wizard Page 1: Select "Delimited"
Wizard Page 2: Tick "Tab"
Wizard Page 3: Select "Text" and finish
Numbers will be stored as text with the leading apostrophe and should import ok in Access
Source
There's probably a better way of doing this though if anyone wants to chip-in.
I'm trying to import a csv file into SQL using SSIS and am hitting a fundamental flaw.
SSIS seems to determine that all fields are varchar(50), even though it correctly identifies the comma delimiter.
This is causing issues when I try to send the data to my table in SQL.
Is there a way of making it recognise that a field of length 3 is actually a field of length 3, and not 50?
Thanks
Yes, there's a Suggest Types function in the Flat File Connection Manager Editor.
Assume you have got a CSV file shown in the first image.
Create a new Flat file connection, and browse this file on your computer. The Columns tab shows the sample of the file.
Click Advanced tab. There you can see all columns have DT_STR type with the length of 50. What you can see is the Suggest Types... button. Click this.
Set parameters as you like. Defaults are all right in my case. Click OK.
Now the first column has the type of DT_STR with the length of 1. (The other two columns have got new types as well. The Number column got DT_I1 (because we choosed the smallest appropriate integer type option), and the Date column got DT_DATE.