Add support for specifying custom patterns #10
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Description
This PR contains the following changes
Code improvements
Upgrade various dependencies and some code cleanup
Remove
timestampand adddatetimecolumn type supportMySQL attempts to convert timezone to UTC when using
timestampcolumns. In order to avoid this we are now usingdatetimeto store date time data instead oftimestamp.Add support for a custom date or DateTime formats
Fixes #11
By default csv2sql will identify date or datetime of the following patterns
YYYY-MM-DDandYYYY-MM-DD hh:mm:ssrespectively.If a csv file contains date or datetime in some other format then they will be imported as varchar by default.
In this PR we add support for specifying custom patterns to import date or datetime data of arbitrary formats.
In order to specify custom patterns for date or datetime use the
--custom-date-patternsor--custom-datetime-patternsarguments followed by a string having one or more patterns separated by;When using the Web UI for csv2sql enter these pattern strings in the config page under "Custom date patterns" or "Custom datetime patterns".
The patterns should be compatible with Timex directives specified here.
Examples
To parse datetime like
11/14/2021 3:43:28 PMa pattern like{0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}can be specifiedThe complete command might look like...
./csv2sql --source-csv-directory "/home/user/Desktop/csvs" --db-connection-string "mysql:root:pass@localhost/test_csv" --custom-datetime-patterns "{0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}"From Web UI
