Python error, while reading CSV file
import pandas as pd
f = 'C:\\Users\\*****\\Desktop\\Emp.csv'
from datetime import datetime
custom_date_parser = lambda x: datetime.strptime(x,"%d-%m-%Y %H:%M:%S")
df = pd.read_csv(f,nrows=100,parse_dates=True,date_parser=custom_date_parser)
df.info()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\readers.py", line 586, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\readers.py", line 488, in _read
return parser.read(nrows)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\readers.py", line 1047, in read
index, columns, col_dict = self._engine.read(nrows)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 309, in read
names, data = self._do_date_conversions(names, data)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\base_parser.py", line 802, in _do_date_conversions
keep_date_col=self.keep_date_col,
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\base_parser.py", line 1093, in _process_date_conversion
data_dict[colspec] = converter(data_dict[colspec])
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers\base_parser.py", line 1055, in converter
return generic_parser(date_parser, *date_cols)
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\date_converters.py", line 100, in generic_parser
results[i] = parse_func(*args)
File "<stdin>", line 1, in <lambda>
File "C:\Users\*****\AppData\Local\Programs\Python\Python37-32\lib\_strptime.py", line 588, in _strptime_datetime
return cls(*args)
ValueError: second must be in 0..59
>>> df.info()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'df' is not defined
second (in date data) should be 3 digit in file, in my case it was 05:33:09345 five digit data. having bad data in csv
Solution
As error clear said, Date format in file doesnt match with the Date pass in code. Seconds of date in CSV file should be of 3 digits only. Verify your data in CSV and try to resolve data in CSV file.
Labels
- Oracle
- Sqlserver
- qlikview
- Sqlserver DML and Functions
- mysql
- Python
- ORACLE dba
- pentaho
- spagobi
- SSAS
- tips and tricks
- office
- Oracle Indexes
- Postgres
- linux
- Hadoop
- Solutions
- Batch
- PHP
- cube
- Buissness Objects
- Cassandra
- SqlDeveloper
- computer
- Datawarehouse
- Project
- SOLR
- SalesForce
- Software
- Sqlserver Indexes
- Talend
- rman
- MongoDB
- News
- SSIS
- Tools
- World's Biggest
- db Tool
- plsql
Friday, September 2, 2022
py0024 Python error, while reading CSV file
DBvisualizer | Not Starting after Install
I have installed DB-visualizer on windows machine, after installation when i click icon to launch application it wont launch. I checked event viewer nothing appear. Then i tried to launch application using CMD and got below error.
Error:
Don't set the -Xmx property too large as it may result in Java not being able to launch DbVisualizer properly. If you experience problems starting DbVisualizer open a file explorer tool on your system and remove this file depending on operating system:
Solution :
Open Below file and set the Xmx properties to 256 or 512
Windows: C:\Users\<user>\.dbvis\user.vmoptions
-Xmx512m
-Xss1m
-XX:StringTableSize=1000003
-Dsun.locale.formatasdefault=true
-include-options ${USERPROFILE}\.dbvis\user.vmoptions
Wednesday, August 31, 2022
MYSQL Error : This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA
Error while executing script in MYSQL workbench
Error
Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
Solution
Execute the below Command in the MySQL console or Workbench:
SET GLOBAL log_bin_trust_function_creators = 1;
For Permanent solution add the below parameter in mysql.ini file:
log_bin_trust_function_creators = 1;
Friday, August 26, 2022
Open Office Writer : Table of Index / Hyperlink
How to Enable Hyperlink in Index Table.
You must have a Open office writer with content and make sure content is marked as Heading 1, Heading 2 , Heading 3,.... Heading n
Next Add Index table Go to Insert > Table of Contents and Index > Table of Contents and Index or bibliography
Index will be added, and you may noticed no hyperlink on index data.
Now right click on Index > Edit Index > Tab "Entries"
Make sure the structure is same as given image LS, E#, E , T, #, LE and Edit LS and LE as Internet Link. Do it for level 1,2,3 as per requirement
Wednesday, August 10, 2022
ORA-39001 ORA-39000 ORA-31640 ORA-27041 OSD-04002 : Oracle IMPDP Error
impdp Scott/tiger full=Y directory=data_pump_dir dumpfile=scott.dmp TABLE_EXISTS_ACTION=SKIP SKIP_UNUSABLE_INDEXES=y EXCLUDE=STATISTICS DATA_OPTIONS=skip_constraint_errors REMAP_SCHEMA=old_schedma_in_dmp:scott logfile=data_pump_dir:scott_full_094358_1.log EXCLUDE=GRANT
After executing above command received error :
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "D:\backups\scott_full.dmp" for read
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 5) Access is denied.
As per error
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 5) Access is denied.
i was assuming that the files or folder do not have correct permission either for window user or oracle user (which is owner of directory)
Looked for many websites while googling, no one able to give the correct resolution for this error, every one is assuming for permission issue.
Problem :
- Using parameter log file wrongly "logfile=data_pump_dir:scott_full_094358_1.log", it should be without "data_pump_dir"
- For another Log File Name ( I am not sure about this), when i use logfile parameter "logfile=scott_full_094358_1.log" it was still giving issue.
Then i modified the log file name to "logfile=scott_full.log" then only it worked for me.
Working IMPDP command
impdp Scott/tiger full=Y directory=data_pump_dir dumpfile=scott.dmp TABLE_EXISTS_ACTION=SKIP SKIP_UNUSABLE_INDEXES=y EXCLUDE=STATISTICS DATA_OPTIONS=skip_constraint_errors REMAP_SCHEMA=old_schedma_in_dmp:scott logfile=scott_full.log EXCLUDE=GRANT
Friday, August 5, 2022
CMD : code to copy the files from 1 folder to another
requirement : Here i have scenario like i have all the files name or image name which i need to copy over to new directory in same computer or on any external drive.
Code
@echo offSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONSET "source=D:\srcdir\"SET "source1="D:\srcdir""SET "destination=D:\Destination"SET "FileNameFromTExtFile=.\Path1.txt"if not exist "D:\Destination\" mkdir D:\Destinationrem copy Folder Structure as of source in DestinationXCOPY "%source1%" "%destination%" /t /eFOR /F "usebackq eol=| delims=" %%f IN ("%FileNameFromTExtFile%") DO (where /Q /R %source1% %%frem echo !ERRORLEVEL!IF "!ERRORLEVEL!" == "1" (@copy /y "%source1%%%f" "%destination%%%f")IF "!ERRORLEVEL!" == "2" (echo "%source1%%%f" is not found!))
In above code it will copy all the files which are mentioned in Path1.txt file and it will loop through all the files and copy to Destination folder from source folder (srcdir).
It will also copy all directory structure before copying the fles.
Feel free to edit code as per your requirement.
how data need to pass in Path1.txt file?
\1C9A7356.JPG
\1C9A7360.JPG
\1C9A7364.JPG
\cam1\1C9A8147.JPG
\cam1\1C9A8163.JPG
\cam1\1C9A8165.JPG
\cam2\SHP04337.jpg
\cam2\SHP04353.jpg
\cam2\SHP04388.jpg
\cam1\DSC_3568.JPG
\cam1\DSC_3571.JPG
\cam1\DSC_3575.JPG
\cam1\DSC_3576.JPG
\cam2\SHP05260.jpg
\cam2\SHP05263.jpg
\cam2\SHP05288.jpg
\cam2\SHP05334.jpg
\cam3\1C9A8935.JPG
\cam3\1C9A8938.JPG
\cam3\1C9A8940.JPG
\cam3\1C9A8942.JPG
CMD : Copy the Folder Structure only
D:\Source>XCOPY "D:\Source" "D:\MyDrive" /t /eDoes D:\Source specify a file nameor directory name on the target(F = file, D = directory)?
After execution of command CMD will ask to enter A or D.
Give Input A if you would like to add output in file and D if you would like create directories.
This command will create folders ( including sub folders) on your specified path without copying the files.
Monday, June 6, 2022
SQL Server Database in Single User Model
Some time you may have notice database status change to "Single User", Once database status changed to "single user" you will not be able to execute query on that database. Below is the solution to change the status of database to "MULTI_USER"
Solution :
SELECT request_session_id, * FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID('databaseName')
Connect to Master database or any other database which is in open state, Copy request_session_id from above query and Kill the session using below command.
KILL request_session_id
USE master
GO
ALTER DATABASE databaseName SET MULTI_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE databaseName SET online
Go
Friday, May 27, 2022
Kettle There was a data type error: the data type of java.lang.Long object [5061] does not correspond to value meta [BigNumber(15)]
: Errors detected!
: Because of an error, this step can't continue:
: org.pentaho.di.core.exception.KettleValueException:
********** BigNumber(15) : There was a data type error: the data type of java.lang.Long object [5061] does not correspond to value meta [BigNumber(15)]
at org.pentaho.di.core.row.value.ValueMetaBase.getString(ValueMetaBase.java:1927)
at org.pentaho.di.core.row.RowMeta.getString(RowMeta.java:328)
at org.pentaho.di.core.row.RowMeta.getString(RowMeta.java:860)
at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:384)
at org.pentaho.di.trans.steps.tableoutput.TableOutput.processRow(TableOutput.java:125)
at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
at java.lang.Thread.run(Unknown Source)
This Error is causing in one of the transformation where components is being used Table Input, Select Value, File Output, and Database lookup
Situation
- Field1 is of Number type size 15
- Field1 is used in "Values to return from the lookup table" in Component Database Lookup
- Checkbox "Enable Cache" was Checked
- Checkbox "Load all data from table" was Checked
Solution
- Uncheck Checkbox "Load all data from table" was Checked
Thursday, May 12, 2022
Local Task Bar appear when Remote Machine done in FULL Screen
You may appear the local machine Task Bar overlap on Remote machine task bar when operating remote desktop in full screen mode (mstsc).
To avoid this Problem just restart the services of Explorer of local machine will fix your problem.
Open you task manager from local machine
Locate the "windows explorer" under Process tab.
Right click and Restart services