I have been successfully using a linked server with SQL Server Management Studio importing a file from Excel which has four columns.
The Excel document looks like (no TOOL means blank cell, rows 6-199)
TDS HOLDER TOOL
1 3 1187
2 4 09812
3 5 9082
4 2 ----
5 76 ----
6 9
7 1
. .
. .
. .
200 18 CT-2989
201 98 CT-9871
When I import it as is, it will grab the cells with the numbers at the top, cells that contain ------ and then when it gets to the cells which are blank it will then print NULL for the rest of the data, which is incorrect.
When I alter my Excel document so that the 'CT' values are at the top, it will grab all of the proper CT and TL values in column 3.
The problem is with the SQl Server Import and Export wizard. It uses the data in the top few rows of the spreadsheet to decide on the data types in each column. When your Tools column has numbers at the top the wizard decides the data type of the column is float. When the column had "CT-2989" at the top it chooses a char type. Once it has chosen the float type it will ignore CT-2989 because it isn't convertable to a floating point number. The simplest solution to the problem it to arrange your Excel spreadsheet with a dummy row at the very top which gives the wizard the proper types for each column. For example, make the first data cell in the Tools column "abcdefg", assuming the rest of the data in that column consists of up to 7 alphanumeric characters. Once your data has imported into SSMS, delete the dummy row.
If you go to the "Review DataType Mapping" page of the wizard it will show that the Tools column has been detected as containing float data when the numeric data is at the top of the spreadsheet. Note that the even if the destination type for the Tools column is nvarchar, the wizard makes it's own decisions regarding source type.
There are other solutions using openrowset() and SSIS, but this one is quick and simple.
Here the problem is with OLEDB which is unable to handel mixed data(numbers + text) so there is no solution only a few hacks some of them already mentioned above I just want to add a few more:-
1) In excel sheet Keep the data consistent and maintain distinct coloumns for each depending upon its data type e.g. text,numeric or whole numbers, fractional numbers etc.
2) Ok before importing it break down the sheet in multiple sheets based on its datatype so that OLEDB won't get confiused.
3) Import the excel sheet in MS Access so that it all the data would get a data type then import it into SQL this would handle NULL too very wisely.
Save the worksheet as .CSV and import as a flat file from task, when reviewing the data, unchecked the Datatypes indicator.
Related
I have data in notepad with more than 1000+ entries, which need to convert in to Excel with particular break based on length. can someone help
011000015FRB-BOS FEDERAL RESERVE BANK OF BOSTON MABOSTON Y Y20040910
File format is as below
Position Field
1-9 Routing number
1 Office code
I tried delimiting option but dint worked out.
If your data always has the routing number in columns 1-9, then delimited import is the way to go. Choose Import From Text, then select Fixed Width and click Next. On Step 2, click at each character that would be a separator. Eg, click at character 9 to split it into two columns with the first column haviong the first nine characters and the second column having the rest. Step 3 will allow you to set the data format. I'd recommend setting the first column to text so Excel doesn't try to use scientific notation or something on your account numbers.
I would like to know how I can count the number of columns of an excel sheet using Talend
If you want to count no. of columns in the Excel file then please follow the below instructions.
Use tfileinputExcel component.
Add some basic instruction in the component with limit 1 but important is "Put one name in Schema 'excel_header' (You can use any name) and change its type to 'Dynamic' ". It will fetch the full row from the excel file.
Now Use second component 'tjavaRow'. Link your excel component through the 'main' row to tjavarow component.
Syn your schema in tjavarow component and put below mentioned code.
System.out.println("Counter ::: "+input_row.excel_heade.getColumnCount());
Now your job will count columns for you.
Note: You can store this counter value in any context variable and can use it.
Thank you
tFileInputExcel (just read 1 row i.e. column headers record) ----> tFileOutputDelimited
tFileInputDelimited (read the file created above) --> tNormalize --> tFilterRow_1 (filter null & blank rows) --> tJava_1
In tJava_1 component, you can get the number of rows by using (String)globalMap.get("tFilterRow_1_NB_LINE_OK").
This number of rows actually represent your number of columns in excel.
I'm trying to be pointed into the right direction of finding a solution of an interesting request I've gotten recently.
An excel file was given to me, with 1 sheet per day, so the year file has 365 sheets, named based on their date.
Now the interesting and also annoying part is that the sheet contains roughly 15 tables, which are not formatted as tables but only visually. See the example here:
The desired format is this:
TABLE NAME -- NAME -- VALUE1 -- VALUE2 -- VALUE3 -- SHEETNAME
Luckily the source format is the same on every sheet. My question is, does anyone know a good method to create a new excel file that takes all this data and combines it into 1 sheet. Which software? Language etc.
So essentially it would be saying, use cell/row X5&&cell/row Y4 as column 1, cell/rowxxx as column 2 etc. (from all sheets available, combined)
Then what I'd want is to import said data and have it transformed/loaded into 1 big new table as described. I previously used pandas dataframe and tabular to merge PDF tables into 1 but these were already actual tables of itself and thus easier. These are basically just cells, visually shown as tables making this quite a nightmare.
Would highly appreciate any creative ideas.
The issue is sorting an array that is generated automatically from an data source using a formula that extracts unique data points. (Data points are date/time)
The data is being extracted with this fomula.
=INDEX(Table_ExternalData_1[SampleDateTime],MATCH(0,INDEX(COUNTIF($G$2:G2,Table_ExternalData_1[SampleDateTime]),0,0),0))
Once extracted, the data is not sorted right away. The current data is extracted from a database via an SQL string that pulls in data corresponding to the data and time that the data point was created.
Because of this, the extracted points are not in the correct order. I am attempting to sort the extracted data points from earliest to latest to continue with the data sorting, but need the date/times to be sorted in a separate row.
I have attempted to use a pivot table, but it isn't exactly what I need and ends up being a messier end product than I need.
All assistance is appreciated.
Example is below.
1
2
3
5
1
2
3
4
6
5
3
I need this.
1
2
3
4
5
6
I did end up finding a solution that I will be able to modify. Using a single row of a pivot table, I took just the date/time column and had the PivotTable function sort the data to be utilized as necessary.
Thank you.
The fact that the range in the example you give:
1) Consists of entries of a numeric datatype only
2) Does not contain any blanks
means that the solution is relatively simple.
Assuming that data is in A1:A11, first use a single cell somewhere within the worksheet to count the number of expected returns. For example, using B1 for this purpose, enter this formula in that cell:
=SUM(IF(FREQUENCY(A1:A11,A1:A11),1))
Your main formula is then:
=IF(ROWS($1:1)>B$1,"",SMALL(IF(FREQUENCY(A$1:A$11,A$1:A$11),A$1:A$11),ROWS($1:1)))
the latter being copied down until you start to get blanks for the results.
Regards
I was going through the XLConnect package reference manual. I came across one function called "SetCellFormula" and its example. I was trying to implement this for data in the text file imported into Excel.
What I wish to do is the following
1. Import data of 200 rows and 400 columns into the Excel file.
2. For each row of data containing 400 columns, compute average, median, minimum and maximum and place the results in another sheet. I want to use the SetCellFormula in case I want to edit the cells directly into Excel, as there are associated features like idx2col, col2idx, ecdt. I find that it is easy to do for a single row. Is there any possibility to do that for all rows in a single statement?
3. Please note that the value for rows and columns can vary based on the type of data available.
Please let me know how to proceed with this.