from google.colab import files
file = files.upload()
df = pd.read_csv('Book 1.xlsx')
df.head(10)
print(df['id'])
When I run this I get a key error for id, which is the first header name in my dataset.
I created this file in numbers by copy pasting text in csv format to a blank numbers spreadsheet and exporting as a csv file. I have "use header names as labels" on in preferences. I have recently gotten my MacBook so there may be some small detail I am overlooking. I have also tried removing footer rows but it isn't working. Please help.
Do you have the head as example because now we are just guessing. And also you are loading a .xlsx file with pd.read_csv while you have the pd.read_excel function in pandas. Maybe that helps?
Also Mohana's answer is worth trying. You are looking on a string and it can be different than you think.
Related
I am using Gnuplot on windows 10, I need to plot some file excel and to do that I copied and pasted evrything in a .dat file (ANSI), but everytime I try to do a simple plot (I mean the only "plot" command) I have this " warning: Cannot find or open file "FolderWhereFileIsLocated/filetoplot.dat"
No data in plot
And of course it is not empty, the file contains this: enter image description here
The file is saved as a .dat , I've also checked many questions about issues like this but I did not have solved, I've also tried to download from the web some other .dat files to test them but without any results.
Can someone please explain me step by step what can I do to make Gnuplot plot my .dat files?
Thanks in advance.
You should take care that your columns are properly separated. In the image you attached are a bunch of white spaces and then a comma separated pair of values, or do you use the comma as decimal symbol?
Save the spreadsheet directly using excel (eg. as csv type and name it *.dat if you want to have it ending like this) and then try to plot it once more.
Whenever I try to upload my dataset to the AutoML Natural Language Web UI, I get the error
Something is wrong, please try again.
The documentation is not very insightful about how my CSV file is supposed to look, but I tried to make a simple sample file just to make sure it works at all, it looks like this:
text,label
asdf,cat
asodlkao,dog
asdkasdsadksafask,cat
waewq23,cat
dads,cat
saiodjas,cat
skdoaskdoas,dog
hgfkgizk,dog
fzdrgbfd,cat
otiujrhzgf,cat
vchztzr,dog
aksodkasodks,dog
sderftz,dog
dsoakd,dog
qweqweqw,cat
asdqweqe,cat
dkawosdkaodk,dog
ewqeweq,cat
fdsffds,dog
bvcghh,cat
rthnghtd,dog
sdkosadkasodk,cat
sdjidghdfig,cat
kfodskdsof,dog
saodsadok,dog
ksaodksaod,dog
vncvb,cat
I chose this formatting according to the Google suggested Syntax
But even with this formatting I still get the same error
I've seen this question Format of the input dataset for Google AutoML Natural Language multi-label text classification but according to the answers there it seems my formatting should work, so I do not know why I get the error
I've just copied the CSV file and uploaded it to my own project and the dataset created worked. One problem is that an extra label was created "label" - this is because the header is not expected to be in the csv file (probably this should get fixed).
Based on that it seems the problem isn't the CSV file format. I would recommend to check if your project is setup correctly. You can open a bug to get someones help. Either you can open a bug in public issue tracker or send feedback using the UI (there is 'Feedback' option in the menu on top right side of the page).
I have found the problem! As Michal K said, there was nothing wrong with the formatting, the real problem was I was not assigned the role of Storage Object Creator, which is necessary because the Data is uploaded in Cloud Storage first
I am using django-import-export library to import several excel books. However, I have over 1,000 books that need to be imported into the db. Is there a way to select a folder to upload instead of selecting and uploading each individual file? I've worked through the tutorial found here: https://django-import-export.readthedocs.org/en/latest/getting_started.html#admin-integration
but I was unable to find the answer to my question.
Any help would be greatly appreciated.
Posting mainly for future viewers. Currently, django_import_export imports only the active/first sheet of a single excel workbook. However, the code is easy enough to modify and alleviate this problem. In forms.py, there is ImportForm which is the one used while importing from admin. Simply change the import_file field to something like this:
import_file = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple':
True}),
label=_('File to import')
)
This form is used in admin.py to process the file data. Change the linked line to something like:
import_files = request.FILES.getlist('import_file')
for import_file in import_files:
...
Now all that's left is to modify the import procedure in base_formats.py for XLS and XLSX formats. The changes will be nearly same for both, I will outline the XLS one here.
Instead of taking the first sheet, run a for loop over the sheets and append the data to the dataset.
dataset = tablib.Dataset()
first_sheet = True # If you keep all correct headers only in first sheet
for sheet in xls_book.sheets():
if first_sheet:
dataset.headers = sheet.row_values(0)
first_sheet = False
for i in moves.range(1, sheet.nrows):
dataset.append(sheet.row_values(i))
return dataset
For XLSX, the loop will run on xlsx_book.worksheets. Rest is similar to xls.
This will allow you to select multiple excel workbooks and import all the sheets for a workbook. I know the ideal solution would be to import a zip file to create all the data using a single bulk_create, but this serves well for now.
We have been programming an application for the next two weeks to make a valid csv file to import to Magento.
But, we have a problem with importing in general, as we get the error that Magento can't find the required columns: sku. I've been looking through a lot of forums.
I have seen it could be the visibility but we have that in our csv. I will give you an example of how our csv looks like:
sku,name,ean,manufacturer,price,msrp,tax_class_id,qty,_category,is_in_stock,status,description,_type,visibility,_attribute_set,color,geluidssysteem,platform_consoles,protection,connection,kabel_lengte,lader,nintendo_platform,model,megapixels,geschikt_foto_video_tas,schermdiagonaal,size,keyboard_layout,geheugen,draagstijl_headset,materiaal,type_camera,type_toetsen,left_right_handed,vermogen,toetesenbord_verlicht,sensorkeuze,stroom_voorziening,connection_mouse,
MRM-01855,AA FUSION AUDIO 3.5mm to 3.5mm Jack kabel 1 meter wit,5060166512163,Advanced Accessories,3.18,,2,6,Nintendo/Nintendo bundels,1,1,Boomsjors,simple,4,PC kabels,Green,,,,Universal,1.8 Meter,,,,,,,,,,,,,,,120w,,,,,
We also had the problem that the description contains a comma and then messes up our csv.
If you need any more information, let me know!
Please make sure you are using the utf-8 encoded file format for your .csv file. This error occurs mostly with wrong formated file content.
To make it correct please open your .csv file in editor and go to 'Save As'-> Select File Type as 'MSDOS CSV(.csv)' and save.
Hope this will help...
What are all the possible MacID("filetype")
I need the one specifically for CSV but i couldn't find a list anywhere online surprisingly.
Just a little aside for this thread.
Yes there are few places to find details of the MacIDs, but beware.
If a file is create on a PC it may not have its MacID set correctly, or at all for that matter.
I am working with Excel files created on both platforms. The XLSX ID is correct if the file is made on Mac but is empty if made on PC.
I have found the best solution is to ignore both forms of wildcards for the two platforms and instead just load all files and use the extension .xlsx
Hope this helps someone
Bob J.
First run:
mdls "FileName"
Find the TypeCode in the Output:
kMDItemFSTypeCode = "TEXT"
You can use:
Dir(Path,MacID("TEXT"))