Import Excel spreadsheet into phpMyAdmin - excel

I have been trying to import an excel (xlsx) file into phpMyAdmin.
I have tried as both excel and csv file. I have tried csv and csv using load data.
I have replaced the default field termination value from ; to ,.
Most times I was getting an variety of error messages, so I deleted my field names column and then was able to import a single row of data only.
The data was off by a column, and I guess that has something to do with the structure of my table, which has a field for ID# as a primary auto-incrementing field which is not in my csv file.
I tried adding a column for that before importing with no success. I would have thought that I could import right from the xlsx file as that is one of the choices in phpMyAdmin but everything I read or watch online converts to csv.
I could use some help here.

I had a similar problem that I solved it by changing the 'fields enclosed by' option from " (double quote) to ' (single quote) and doing the same to the first line of the file which contains the field names. Worked like a charm. Hope this helps.

This is hopelessly late, but I'm replying in the hope that this might help a future viewer.
The reason that the CSV data is off by one is the very fact that you don't have the ID# field in it! The way to get around this is to import the file into a temporary table, then run
INSERT INTO `table`
SELECT NULL, <field1>, <field2>...
FROM `temp table`;
Adding NULL to the list of fields means that MySQL will autogenerate the ID# field (assuming you've set it to AUTO_INCREMENT).

Related

How to Link a Excel Table with Access and prevent NULL Values due to wrong Data Type Conversion?

In the current Project i Need to Keep a Excel File which gets Values from a Machine to the Access Database to work with them and Import them in the Data Model.
Problem is some of the Values give invalid results due to the way they are saved. For example the timestamp is saved like
030420 instead of 03:04:20 and Access cant handle that and gives me a #NUMBER
I can not simply Change the datatype in Excel because the whole Excel gets refreshed every hour by a source that i cant influence.
Any help appreciated.
If Erik's proposal does not work, you can
- create a backup copy of your Excel source
- tweak the file: enter text in the first row of the problematic columns
- link the tweaked file into Access
- put back the real file in place.
Now the problematic columns should be read as Text, and you can build a query that solves any issue like conversion, null handling...
Link, don't import, the Excel file, and you have a linked table.
Now, use this linked table as source in a simpel select query where you modify the data and alias the fields as needed. For example:
Select
F1 As SomeName,
F2 As OtherName,
TimeSerial(Mid([F5],1,2),Mid([F5],3,2),Mid([F5],5,2)) As TrueTime
From
LinkedTable
Where
F7 Is Not Null
The use this query for your import.
Consider querying the Excel file instead of using a linked table.
The query can directly query an Excel range:
SELECT * FROM
[Excel 12.0 XML;DATABASE=PathToMyExcel;HDR=Yes;IMEX=1].[MyRange] t
Then, you can use functions like TimeSerial to cast numbers to time values.

CSV Export Automatically converting value of functionally created text version of SQL date format, from filemaker standard to something weird

i have exported a .CSV from filemaker so i can import the .CSV into a MySQL database. The issue i am getting is that the CSV is automatically thinking that the data is some form of custom formatting and then turns the data into something completely wrong. But that's not the most stupid part, i can click inside the formula bar and see THE FREAKING VALUE I EXPORTED. i have tried to format the cells and it doesn't seem to do much for me, but i noticed that if i manually prepend a "'" into the formula bar it will work. i just really dont want to do that 4300 times for ~6 fields, so do any of you have any ideas what went wrong, or how to fix it?
Heres an example:
12:16:42 AM turns into 16:42.0

Access VBA - Import problems

I'm importing some data form Excel into Access and I'm facing some strange issues.
Problem:
I'm using DoCmd.TransferSpreadsheet Method to import Excel data into Access like this :
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "Excel_Data", "Filename", True
This "Excel_Data" table is not pre-created so Access creates It on It's own. Why ? If I pre-create It, then User has to import data to Destination table from Excel in exactly same order (column A in Excel is row 1 in Access etc..).
But If you don't pre-create It, then Access creates whatever table there is in Excel and you can Import only data that you wish - based on column names. Now here is where It get's stucked....
I don't know why, but on every other Imports I do like this, Access creates only Text fields - and then my Import to destination table works.
But in one of the Imports Access creates a Number field, and then Import into destination table doesn't work anymore. All Excel data are formatted as general.
Does anybody know how to avoid this ???
Basically I want just to Import excel data into Access, based on column names, in whatever column order there is in Excel.
thanks for help !
I would suggest to use the query like this instead of TransferSpreadsheet
SELECT * INTO Table1
FROM [Sheet1$D3:E24]
IN "C:\Temp\Test.xls" [Excel 12.0;HDR=YES;IMEX=1];
Note, that IMEX=1 allows you to suppress data type guessing and Access will create always text fields.
Also this will allow you to import data from specified ranges of spreadsheet and use WHERE clause for filtering unnecessary data
Thanks for all answers, but I have solved this on my own. Best thing to avoid any problems when doing Import is simply using ALTER Table command after DoCmd.TransferSpreadsheet method is done. I just altered all my columns to Text format, changed all my other tables to Text fields and now every manipulating with data works just fine.

APPEND FROM excel sheet gives strange error

I have a problem with the APPEND FROM statement in Visual FoxPro. I cannot do an APPEND FROM an excel sheet without getting this error:
Function name is missing (
I'm working on processing some legacy data stored in a FoxPro database. I'm reading it, processing it in .NET, and then writing it back to a new FoxPro database. However, the writing part is not working. Unfortunately using another database is not an option. And yes, I am a FoxPro newbie.
I do get INSERT statements to work, but it would be useful if I could get APPEND FROM an external file to work as well, AND also be able to hydrate memo fields. Afaik you can't do that with CSV files in FoxPro, only Excel and some other formats - but not CSV.
To demonstrate the problem I'm using the Address Book sample database that comes with Visual Foxpro.
I run this query in the query window in V.FP:
USE "ADDRESS BOOK!ADDRESSES"
APPEND FROM D:\tmp\excel_data2.xls FIELDS (addressid, firstname) DELIMITED XLS
The .xls file is a Excel 97-2003 workbook and looks like this:
A | B
------------------------
23 | Sample 1
------------------------
24 | Sample 2
I think the syntax should be correct according to this doc: http://msdn.microsoft.com/en-us/library/aa977271(v=vs.71).aspx
However, running this query just gives me the error about "Function name is missing (" . I've tried all sorts of rewrites and variations of this query that I could think of, but I just can't figure out what the problem is. Any help would be appreciated, thanks.
Not to steal the show, but this is how I got it working:
Ensure the XLS file is stored in the Excel 5.0/95 format (basically an ancient Excel format, but more than sufficient for data entry).
Close the Excel file, otherwise you will get an error about the file being locked/open in another app.
I used the following amended APPEND FROM statement and it worked:
USE "ADDRESS BOOK!ADDRESSES"
APPEND FROM D:\tmp\excel_data2.xls FIELDS addressid, firstname XLS
LAK was correct, but I will clarify for your app and possible future encounters with Excel imports. If your table does not match the columns order in Excel, you could run into problems. Typically I import into a cursor that I know the order and format of the fields. Then I'll append from. Once in a cursor version of a table, I can then append to any other table, cycle through it, do data cleansing, etc.
Say your address table had it's structure of ID, LastName, FirstName, Address... but your Excel file had ID, FirstName+LastName as a single field, Address and you know you will need to parse it into proper first/last fields. This would be a good example of using the interim cursor. If the cursor has more columns than Excel, they will just come along for the ride and be blank, but there to work with as you need.
create cursor C_TmpFromExcel;
( IDCol int,;
FullName c(40),;
Address c(35),;
FirstName c(20),;
LastName c(20) )
append from D:\tmp\excel_data2.xls type xls
*/ VERY BASIC example to split the name
replace all lastname with left( fullname, at("," , FullName ) -1 )
replace all firstname with substr( fullname, at( ",", FullName ) +1 )
select LiveAddressTable
append from C_TmpFromExcel
When appending one table (or cursor) together with another, VFP will handle match by same column names and disregard those where the column(s) are otherwise extra and not needed (such as the sample "FullName" column -- vs the FirstName extracted as extra ).

Excel Source in SSIS Column limitations

Can we import data from Excel with more than 256 fields in to a SQL database using SSIS. If so is there any trick for this, as I couldn’t see more than 255 columns in the column selection at Excel source in SSIS
Yes, I had to save the Excel file as CSV, and then I had access to all 360 columns in my import file.
NOTE: Because I wanted to save errors out in the same format, I needed to have my ERRORS file in CSV as well, and the error file had to exist when I set up the connection to it, with only the column headings in the first row, so that all the columns would map automatically in SSIS.
If you mean you couldn't see more than 255 rows in the Data Source Component's preview within SSIS then that is expected since I believe that is the most it will show you. Of course all the rows will be imported.
As i tried all avenues with no success, i tried converting the excel file in to a tab delimited text and tried the import. It worked superb..
you could use two data sources to load the data then join them together as explained in this Post

Resources