Coder Social home page Coder Social logo

stride - invalid command about pg_bulkload HOT 6 CLOSED

mybigman avatar mybigman commented on September 24, 2024
stride - invalid command

from pg_bulkload.

Comments (6)

mikecaat avatar mikecaat commented on September 24, 2024

Hi,

Though I took a fast look, the "stride" seems to be supported for only binary not csv.

http://ossc-db.github.io/pg_bulkload/pg_bulkload.html

Binary input format
STRIDE = n
Length of one row. Use if you want to truncate the end of row. The default is whole of the row, which means the total of COLs.

from pg_bulkload.

mybigman avatar mybigman commented on September 24, 2024

@mikecaat - looks like your spot on, thanks.

I am trying to move from mariadb to postgres and their "copy" command is not very flexible compared to "mysqlimport".

We digest huge csv files daily and the way the csv files are they have an additional separator at the end if its an empty field or not.

a^b^c^d^^
a^b^c^d^e^

The files are just to large to run "sed" over them and haven't found a clean way of handling this :/

from pg_bulkload.

mikecaat avatar mikecaat commented on September 24, 2024

Hmm, is the following your expected result?

$ cat /tmp/test.csv
a^b^c^d^^
a^b^c^d^e^
psql=# CREATE TABLE test (a text, b text, c text, d text, e text, f text);
CREATE TABLE
psql=# COPY test FROM '/tmp/test.csv' WITH (FORMAT CSV, DELIMITER '^');
COPY 2
psql=# SELECT * FROM test;
 a | b | c | d |   e    |   f
---+---+---+---+--------+--------
 a | b | c | d | (null) | (null)
 a | b | c | d | e      | (null)
(2 rows)

from pg_bulkload.

mybigman avatar mybigman commented on September 24, 2024

Whoops sorry my mistake...

I comes likes this. It always adds one extra regardless :/

a^b^c^d^^^
a^b^c^d^e^^

The other hassle is that when they decide to add new fields to the end of the csv file we have to race and update the table with the new fields.

With mysqlimport any additional field is completely ignored and still loads the table, this gives us time to add extra fields at our leisure.

from pg_bulkload.

mikecaat avatar mikecaat commented on September 24, 2024

Oh, that’s hassle.

Though there are some workaround including using the pg_bulkload’s Fillter function, I agree that mysqlimport’s way is better for your case.
https://stackoverflow.com/questions/12618232/copy-a-few-of-the-columns-of-a-csv-file-into-a-table

from pg_bulkload.

mybigman avatar mybigman commented on September 24, 2024

Thanks mate for the info... I will see what I can come up with that's some what reliable, otherwise we will be sticking with mariadb :)

from pg_bulkload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.