Importing CSV and required data fields

dBase, Calc, CSV, MS ACCESS, MySQL, PostgrSQL, OTHER

Importing CSV and required data fields

Postby dsears » Sun Mar 03, 2013 8:52 pm

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
dsears
 
Posts: 2
Joined: Sun Mar 03, 2013 5:48 pm

Re: importing CSV and required data fields

Postby Villeroy » Sun Mar 03, 2013 9:05 pm

menu:Tools>SQL...
Code: Select all   Expand viewCollapse view
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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24650
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: importing CSV and required data fields

Postby dsears » Sun Mar 03, 2013 11:54 pm

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
dsears
 
Posts: 2
Joined: Sun Mar 03, 2013 5:48 pm

Re: importing CSV and required data fields

Postby Villeroy » Mon Mar 04, 2013 11:44 am

Code: Select all   Expand viewCollapse view
ALTER TABLE "Your Text Table" ADD COLUMN "B" BOOLEAN DEFAULT FALSE;

(same as above but with Null allowed)

Code: Select all   Expand viewCollapse view
UPDATE "Your Text Table" SET "B" = FALSE;

(fill with False)

Code: Select all   Expand viewCollapse view
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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24650
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Importing CSV and required data fields

Postby cderees » Wed Jul 30, 2014 10:22 am

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
cderees
 
Posts: 2
Joined: Tue Jul 29, 2014 1:03 am


Return to External Data Sources

Who is online

Users browsing this forum: No registered users and 2 guests