Reading XLSX data in SpringBatch - apache-poi

I have an xlsx file that has to be read and the date field needs to be written to MYSQL DateTime column.
The date in the excel file is in the format " 2018-08-06 16:32:58"
But when I read it using PoiItemReader and then convert it in a custom rowmapper, I get the below exception :
java.text.ParseException: Unparseable date: "1533553378000"
at java.text.DateFormat.parse(DateFormat.java:366)
at org.springframework.batch.item.excel.RowMapperImpl.mapRow(RowMapperImpl.java:63)
I feel that this is due to PoiItemReader not being able to read the date field correctly. Please note that I have tried converting it into sql date using SDF.
Code: https://github.com/vishwabhat19/TimeWorkedData.git
Should i be using XSSFWorkbook instead ? And if I do how would i push this into a Reader? My project is a spring batch project and it needs a InputReader object.
Thank you in advance.

Related

Export json type filed to CSV

I have exported data from my data base which contains 25 fields .Out of these 25 2 of them are in json format .When I exporting it and delimiting it with ','(comma).It realy looking bad .The json value are also getting delimited.
after opening its getting delimited by , and result looking worse.
Any workaround for this.Thanks in advance
Note:I am using ms excel

BigQuery load parquet file

I am trying to load a parquet type file into the bigquery table.
However, the date type column in the yyyy-mm-dd format is recognized as a String, and the following error occurs.
ERROR - Failed to execute task: 400 Provided Schema does not match Table my_prj.my_dataset.my_table. Field _P1 has changed type from DATE to STRING.
field_P1: 2022-10-05
Is there any way to solve it?
The first solution that comes to my mind is to load the data using Pandas library in Python. This way, you can convert string to related date format and load the data directly to BigQuery.

Date Formats When Reading Excel with SSIS

experts!
I've got two similar Excel files (xlsm) as templates. Both have sheets with Date column.
Visible format for both files when use Excel is "10-Aug-20".
But when I read these files with SSIS process with Script Component Source using Microsoft.ACE.OLEDB.12.0 with "IMEX=1"... ta-da... some I see as expected, but some are 10.08.2020 00:00:00
This causes me a lot of pain because I will process files from both US (MM/dd/yyyy) and German (dd.MM.yyyy) date formats and would like to have locale-independent date format to process dates same way.
How can I force excel to give or ssis to read a correct date format.
Any suggestion how to see both files same programmaticly is most wanted and highly appreciated!
You could try to use the script component (as Transformation) to transform the data by using DateTime.TryParseExact
string dateString = "10-Aug-20";
string format = "dd-MMM-yy";
DateTime dateTime;
if (DateTime.TryParseExact(dateString, format, "en-US",DateTimeStyles.None, out dateTime))//if (DateTime.TryParseExact(dateString, format, "de-DE",DateTimeStyles.None, out dateTime))
{
Console.WriteLine(dateTime);
}

Problem, reading date field from visual foxpro dbf file

when I try to get data from dbf file to Excel PowerQuery, using Visual Foxpro OLE DB provider all is ok except date field - I get 1899-12-30. The same result when I try to do that with C# + OLEDB.
When I just open this dbf file with Excel, instead of date string I see symbols like that:Ü|%
How to read/convert dbf date field correctly?
Actually, the Dec 20, 1899 is basically an empty date is intentional. Going WAYY WAYYYY back, I can't remember the exact time I needed, but that was like a baseline date within Excel. When trying to read in dates from Excel, I would have to add the number of days between date() and date(1899,12,30) to get correct date. It should not be considered a garbage value.
The problem was non standard dbf date field format - instead of 8 bytes it takes 4 bytes only (after analyzing with hex viewer). So, Visual FoxPro OLE DB provider could not interpret it correctly.

PHPExcel: importing xls, date format to Y-m-d

Following the examples provided in the documentation (in particular example 07reader.php) I have managed to extract all the data I needed from an excel file.
However the files I need to import have date values that need to be converted to Y-m-d, so I was wondering if PHPExcel can always output dates in a certain format.
Does anyone know hot to do it? I've looked in the official forum, but I haven't found any solution, and I didn't get how to do it looking at the documentation.
PHPExcel will show date formats according to the defined format mask. There are a number of helper functions available that will allow you to convert an Excel timestamp value to a PHP/unix timestamp or to a PHP DateTime object: like PHPExcel_Shared_Date::ExcelToPHP() and PHPExcel_Shared_Date::ExcelToPHPObject()

Resources