Importing CSV and required data fields

dBase, Calc, CSV, MS ACCESS, MySQL, PostgrSQL, OTHER
Post Reply
dsears
Posts: 2
Joined: Sun Mar 03, 2013 5:48 pm

Importing CSV and required data fields

Post by dsears »

I can successfully import a CSV file into a table. But I would like to make one of the columns in the table contain a boolean field type that is both required and has a default value of false. I've tried doing this in different ways:

* directly, because there is an option for "entry required" in the type formatting dialog
* indirectly, by not selecting the "entry required" option and then attempting to set it afterwards
* adding a column afterwards

None of these approaches work. Is there any way around this?

Thanks.
Open Office 3.5, Linux, Windows & Mac
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: importing CSV and required data fields

Post by Villeroy »

menu:Tools>SQL...

Code: Select all

ALTER TABLE "Your Text Table" ADD COLUMN "B" BOOLEAN DEFAULT FALSE NOT NULL;
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
dsears
Posts: 2
Joined: Sun Mar 03, 2013 5:48 pm

Re: importing CSV and required data fields

Post by dsears »

Thanks. I'll look at it because that looks like a useful technique. But this turned out to be pilot error. I was importing a column without any values in it. When I added 0's to the column, it was easy to import the data into the table.
Open Office 3.5, Linux, Windows & Mac
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: importing CSV and required data fields

Post by Villeroy »

Code: Select all

ALTER TABLE "Your Text Table" ADD COLUMN "B" BOOLEAN DEFAULT FALSE;
(same as above but with Null allowed)

Code: Select all

UPDATE "Your Text Table" SET "B" = FALSE;
(fill with False)

Code: Select all

ALTER TABLE "Your Text Table" ALTER COLUMN "B" SET NOT NULL;
(disallow Null)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
cderees
Posts: 2
Joined: Tue Jul 29, 2014 1:03 am

Re: Importing CSV and required data fields

Post by cderees »

I was interested to read that you were able to import from a CSV file into Base tables. Could please ask how you are to do this?
OpenOffice 4.1.0 with MacOS 10..4
Post Reply