You need to adapt this Tool for your own requirements. You can possibly use the SchemaBuilder[0] to build a schema @Runtime which you would then pass to DataFileWriter.write(schema, outStream). Thats how I would try it over then refine it for your use case. Any others ideas?
[0] http://avro.apache.org/docs/current/api/java/index.html?org/apache/avro/SchemaBuilder.html On Tue, Jul 8, 2014 at 5:10 PM, Bhuvana Bellala < bhuvana.bell...@cormac-corp.com> wrote: > Hi Lewis > > > > Thanks for your reply! I have been looking into these tools. The > fromtext tool uses “bytes” as a default schema and I have not found a way > to specify schema to this tool. Is there any way I can specify a schema for > the text file and convert it into avro?. > > > > > > *From:* Lewis John Mcgibbney [mailto:lewis.mcgibb...@gmail.com] > *Sent:* Monday, July 07, 2014 5:30 PM > *To:* user@avro.apache.org > *Subject:* Re: COnverting CSV files to avro and back to text > > > > Hi *Bhuvana* > Have you checked out the Tools module? Some really helpful utilities in > there which you can either use or use for motivation for achieving exactly > what you are after. > In particular... > > https://svn.apache.org/repos/asf/avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/FromTextTool.java > > and > > https://svn.apache.org/repos/asf/avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/ToTextTool.java > > HTH > Lewis > > > > > > On Mon, Jul 7, 2014 at 5:13 PM, Bhuvana Bellala < > bhuvana.bell...@cormac-corp.com> wrote: > > Hi, > > > > I want convert a CSV file into avro format so that I can compress data > and do some map reduce things in Hadoop. And then I want to convert the > avro data back to text. Are there any tools to do this? I know I could use > hive to do this but I want to know if there are any other ways to do this? > Thank! > > > > [image: Cormac_logo] > > > > *Bhuvana Bellala| Intern* > * ------------------------------ * > > *13921 Park Center Road, Suite 180, Herndon VA 20171|* > > *CMMI Maturity Level 3 Rated| GSA Schedule 70| SBA SDB, 8(a)*| > > www.cormac-corp.com > > > > This email and any files transmitted with it are confidential and intended > solely for the use of the individual or entity to whom they are addressed. > If you are not the named addressee you should not disseminate, distribute > or copy this e-mail. Please notify the sender immediately by e-mail if you > have received this e-mail by mistake and delete this e-mail from your > system. If you are not the intended recipient you are notified that > disclosing, copying, distributing or taking any action in reliance on the > contents of this information is strictly prohibited. > > > > > > > > > -- > *Lewis* > -- *Lewis*