SSIS Excel Destination exporting data with leading apostrophe - excel

i cant believe i am struggling with this so much. you would think that since SSIS and Excel are both Mirosoft products they would interact seamlessly...
I have some data in a SQL Server table which i want to export to Excel. None of the data in any of the columns in SQL server have a leading apostrophe. So the solution is not use REPLACE.
Once I create an empty file through the Excel Destination task I open the file and format the columns to what I need them to be save and close the file. I run the package when i open the file all columns are preceded with a ' e.g. 'WA or '1234. If i recreate the file again following the procedure above and i format the columns and enter data into the first row, save the file and rerun the package, the data in the excel file is inserted correctly without any leading '.
How do i remove the leading apostrophe without having to insert a template row?
What is the best practice solution for this? The data is going to be uploaded into another database at another company and they dont want the leading apostrophe's.

Related

Automatically convert csv file into Excel table?

I generate some csv files using a script. Next I manually convert those csv files into excel tables using the import wizard in excel based on:
https://www.youtube.com/watch?v=z5Pxil4jVO4
Is it possible to do this automatically - e.g. by calling an excel importer from command line - so I don't need to open excel and do all the manual work?
I can open the csv file directly in Excel but its not formatted as a table. E.g. this csv file:
a,b,c
a,b,c
results in this Excel sheet:
I would like each letter to be in a separate column.
I have looked at this:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/370ee470-f2cd-4f30-a167-b106dd51d47a/powershell-convert-csv-to-xlsx?forum=winserverpowershell
but its an awful lot of boiler plate code from create a simple table.
Add an extra line to your CSV file to tell Excel what the seperator is. Add the following line to the top of your CSV file:
sep=,
The easiest way, without close and edit your file - you can choose which separator you want in Excel 2010-2016 go to DATA, Text To Columns, choose Delimited, then choose your separator Comma (or other) and you will see changes immediately in the "Data preview", then click FInish.
Once you have the format you wanted, you simply save the document and it will be permanent.

Opening CSV file

I am generating CSV files. My first row it is column names, and it looks like
User ID;First Name;Last Name;Email;...
But if I will change User ID to ID, MS office cannot open this CSV and shows me error
Cannot read record(number of record)
But this file opens correctly on, Notepad++. I am using Excel 2013. Any ideas what is wrong?
You can solve the problem by inserting the following simple text at the beginning (the first line) of your .csv file:
sep=;
This will not be seen when the file is opened in Excel. What it will do - it will explicitly tell Excel that the delimiter is ;, and values will be separated into separate cells. Also, you will be able to use ID as the title of a column. Unfortunately, I cannot answer why Excel does not like it when you use this title at the beginning of the file.

replacing data source from Excel to csv in a functioning Tableau workbook

I have a functioning Tableau chart using multiple data sources, one of them being an Excel file.
I now want to replace the Excel file with its equivalent csv (same content and structure). However, I can't seem to find the way to do it. Simply replacing the data source in Edit Data Source gives an "Unexpected Error" where the detail says "Illegal file type for Excel protocol" (not that unexpected error if you ask me).
Is there a way to do so without needing to rebuild the charts which use the fields from this data source?
Connect to the csv (extract if you will, I strongly recommend you do).
Make sure all the fields in the csv has the same names of that in the Excel.
Now right click the excel data connection and choose replace data source. Now replace the excel data source by the csv one.
If there are calculated fields on the excel data source, I recommend you copy and paste on the csv (inside Tableau, after the connection)

CSV file contains trailing pipe delimiters

I have an excel file and I exported the file into a pipe delimited csv file. However, in each row of the csv file, there are trailing pipes.
Here's a typical row:
dsad|asd|safd|sadaf| |||||||||
ddss|sd|saadfdaf|dadf |||||||||
Does anyone know how not to include those trailing pipes while exporting to csv from excel?
Thanks.
The sheet you are exporting probably contains cell that excel believes has values in them (I call them ghost cells). To prevent this behaviour, I have two suggestions:
Copy the spreadsheet to a fresh new spreasheet and export again. It should be fine.
Delete all the columns after the last column containing data (Do not use the Delete/Del key, select the columns till the end and use Ctrl+- instead). After this, save the workbook then export again.
If those don't work, there's probably some rows with actual data somewhere, and there, the data will be correctly delimited by the pipes. Might be best to count the number of columns of data that you have and make sure your resulting csv file has the same number of columns.
If this still doesn't work... just shout I guess? ^^;

Excel and Tab Delimited Files Question

I am encountering what I believe to be a strange issue with Excel (in this case, Excel 2007, but maybe also Excel 2003, but don't have access to it as I write this).
I can reliably convert some server data over into a tab-delimited format (been doing this for years) and then open it using Excel - no issue.
However, what seems to be happening is if I have an html <table> inside one of the fields, it looks like Excel 2007 thinks it should be converting the table into rows and columns inside Excel (not what I want). As you might imagine, this throws off the entire spreadsheet.
So question is, is there any way to set up excel to NOT do this (perhaps some setting in Excel that pertains to reading tab delimited files), or am I missing something?
Thanks.
Save your file as .txt
Now open the file in excel using Drag and Drop (rather than double clicking your hookey .xls)
Slightly more work to open the file, but your tab text formatting will now be respected.
When you open the tab-delimited file, you are shown an import mapping dialog that lets you pick each columns' data type (date, text, currency, etc.). For the columns that have HTML data present, choose text. This will tell it basically to import as-is and not try to automatically parse the data into a derived format.
Excel 2003 does the same. I don't think there is a way to do it with a config because Excel finds delimiters in the html table and breaks the html in cells and columns as it does for the other columns.
If the column containing html is always the same, you can use JYelton suggestion of renaming the file as csv and record a small VBA macro to load the file selecting automatically the html column as text in the import mapping dialog and you load the file calling the macro instead of double-clicking on the file.
If nothing else, import it into OpenOffice.org Calc, save as an .xls file, then open in Excel.

Resources