Hmm actually I just now realized that you can completely omit the Drop Table part ... if you use create table on an empty file, it will simply create the header.
2014-07-16 23:10 GMT+02:00 Kasper Sørensen <[email protected]>: > Yes, you do that while creating the table. Like this: > > CsvDataContext dc = ...; > dc.executeUpdate(new UpdateScript() { > @Override > public void run(UpdateCallback callback) { > callback.dropTable(dc.getDefaultSchema().getTable(0)); > > callback.createTable(dc.getDefaultSchema(), > "newtable").withColumn("foo").withColumn("bar").execute(); > } > }); > > (replace with your own column names of course) > > > 2014-07-16 23:04 GMT+02:00 Júnior <[email protected]>: > > Hi Kasper, >> >> thanks for your reply, but what about the columns? >> >> Do I need to add columns to this newly created table? >> >> Att. >> >> >> 2014-07-16 18:00 GMT-03:00 Kasper Sørensen < >> [email protected]>: >> >> > Hi there, >> > >> > There is a little known trick to get around that issue, so I guess it's >> a >> > very fair question. >> > >> > The trick is to first do a drop table, and then a new create table. >> > >> > When MM is initialized with an existing empty file, it will determine >> that >> > there IS a table, since the file is there, but that table has no >> columns, >> > because the file does not define any columns. Maybe it's a bit silly - I >> > actually think that's worth discussing ... But the reason it is there >> is I >> > guess to indicate that at least the file is there, it's not a >> non-existing >> > file (in which case there would not be any table). >> > >> > Best regards, >> > Kasper >> > >> > >> > 2014-07-16 21:37 GMT+02:00 Júnior <[email protected]>: >> > >> > > Hi, >> > > >> > > I'm trying to use the metamodel to write on an empty csv, >> > > >> > > But I'm getting errors saying that there is no column. >> > > >> > > I was able to do that calling create table with a different name from >> the >> > > file. >> > > Then added the columns. >> > > >> > > I worked, but it created the header line with the column names, would >> it >> > be >> > > possible to do that without adding the column names in the csv file? >> > > >> > > Att. >> > > -- >> > > Francisco Ribeiro >> > > *SCEA|SCJP|SCWCD|IBM Certified SOA Associate* >> > > >> > >> >> >> >> -- >> Francisco Ribeiro >> *SCEA|SCJP|SCWCD|IBM Certified SOA Associate* >> > >
