Return-Path: X-Original-To: apmail-metamodel-dev-archive@minotaur.apache.org Delivered-To: apmail-metamodel-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5E54210F96 for ; Wed, 16 Jul 2014 21:12:57 +0000 (UTC) Received: (qmail 21365 invoked by uid 500); 16 Jul 2014 21:12:57 -0000 Delivered-To: apmail-metamodel-dev-archive@metamodel.apache.org Received: (qmail 21328 invoked by uid 500); 16 Jul 2014 21:12:57 -0000 Mailing-List: contact dev-help@metamodel.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@metamodel.incubator.apache.org Delivered-To: mailing list dev@metamodel.incubator.apache.org Received: (qmail 21312 invoked by uid 99); 16 Jul 2014 21:12:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jul 2014 21:12:56 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of i.am.kasper.sorensen@gmail.com designates 74.125.82.47 as permitted sender) Received: from [74.125.82.47] (HELO mail-wg0-f47.google.com) (74.125.82.47) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jul 2014 21:12:53 +0000 Received: by mail-wg0-f47.google.com with SMTP id b13so1503827wgh.6 for ; Wed, 16 Jul 2014 14:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=oV9zqZy/0pWgrRYIpYubML2/KbvMOcFqDoh0MWR1F4Y=; b=UFZkZTHb4YHVA2VkJjjOPbMYpBg6k2jCytO+yYxSFt8H4/2HKOVQBjBNG2MDfWFyzP q9Mhf0IZTQR+eG36e+isUsOuw3rtSQ2F0DjQf9rB+a37O1vQENyJiBxi9zn5JB1lmPbW 0VvT5EDKV3mrecfIpGw7hKGfX8OFCQdWS7mIXrFxW4xdblsYQTV8eUYxkaalDUkZQiQa I5kpiU9cqLrVE9Q2nh2x145Xn21ojpDzRSE2Yw03rW3+2Fp03jP23cYiwy2Qn/vxKcy4 bBSmdfUhHMsdMu3HCB0935WUjKD0ueAEHlKIBdIwU5Cc9TUdecYqlBJlTYj3ecevRkfh +zsQ== MIME-Version: 1.0 X-Received: by 10.194.2.132 with SMTP id 4mr39396099wju.49.1405545149289; Wed, 16 Jul 2014 14:12:29 -0700 (PDT) Received: by 10.194.163.7 with HTTP; Wed, 16 Jul 2014 14:12:29 -0700 (PDT) In-Reply-To: References: Date: Wed, 16 Jul 2014 23:12:29 +0200 Message-ID: Subject: Re: Create a CSV in a empty file From: =?UTF-8?Q?Kasper_S=C3=B8rensen?= To: "dev@metamodel.incubator.apache.org" Content-Type: multipart/alternative; boundary=047d7b343d6c56da9504fe55fb6f X-Virus-Checked: Checked by ClamAV on apache.org --047d7b343d6c56da9504fe55fb6f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=B8rensen : > Yes, you do that while creating the table. Like this: > > CsvDataContext dc =3D ...; > 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=C3=BAnior : > > 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=C3=B8rensen < >> i.am.kasper.sorensen@gmail.com>: >> >> > 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=C3=BAnior : >> > >> > > 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 fro= m >> the >> > > file. >> > > Then added the columns. >> > > >> > > I worked, but it created the header line with the column names, woul= d >> 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* >> > > --047d7b343d6c56da9504fe55fb6f--