Hi Freinds ,
I want to convert the files that are in text format (.txt) to CSV file. I am working on Linux. So can anyone guide me.
Here is my problem Description
I have some result files which contains text fields and numeric fields which are seperated by tab and also there is a - between two numbers 10-20 .
Another thing is that colons are also present in between in files
name :: praveen
Also my another concern is if have different kinds of output fields in the file how to convert those into csv. what i mean is , for example if there is a text file in which i will have the following fields
Name Age Location School College
So in the result files all the above columns may be present or any of these may be present . But minimum first 3 columns will be present . So what is the solution . Does the csv file contain a blank if the values are not specified ?
Then how should i convert these kind of text files into csv file (Comma Seperated values) Files .
Should i write my own code or is there any utilities that can help me convert these text files into csv files
Thanks in advance
Praveen
5 3144
I think a Linux tool such as awk or sed might be of more use to you in this case - you can use those to replace the tabs with the commas (or is it not currently in the format you want?).
What is the format of the current file, specifically? (Can you post two lines from it so we can get an idea?)
A csv file is a file with entries delimited by a comma (which can be opened in excel among other things).
Assuming you want every tab space in the text file to be a "breaker" between columns, then it is a matter of replacing the blank with a comma. Assuming you want to split the hyphenated numbers, then you also replace the hphen with a comma (otherwise you can treat it as text).
a blank cell will be recognised if you add two commas (that is, if you need to pad out to 3 columns, just add commas until it pads far enough).
I think a Linux tool such as awk or sed might be of more use to you in this case - you can use those to replace the tabs with the commas (or is it not currently in the format you want?).
What is the format of the current file, specifically? (Can you post two lines from it so we can get an idea?)
Thank you for your reply. I solved the problem by writing some programs .
Thank you DeManfor the response and reply. I wanted some clarifications regarding csv from you all 1) Should we include the column header in csv for example consider the below data
Age Location
25 California
26 London
27 Rome
28 Amsterdam
In my csv file should the header Age,Location be placed or only the data should be there .
For example which of the below is the correct format of csv file
Below Data is with Header (Age,Location)
Age, Location
25,California
26,London
27,Rome
28,Amsterdam
Now the data below this line doesn contain header , only pure data
25,California
26,London
27,Rome
28,Amsterdam
So which one of the above is in correct csv format
2)Whether each line in the csv file should end with a new line character or the data should be written into csv file continously
for example :
25,California,26,London,27,Rome,28,Amsterdam
So i will be very thankful to u all if you clarify my these doubts
If the header is important then include it in the csv (as you might have noticed though, the formatting/underlining etc is ignored)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Eric |
last post by:
Assume that disk space is not an issue
(the files will be small < 5k in general for the purpose of storing
preferences)
Assume that transportation to another OS may never occur.
Are there...
|
by: Steve |
last post by:
My application uses transfertext to create text files that are FTPed to a
website and are processed by a webstore. The text files can be for one of three
purposes: Add one or more items to the...
|
by: thenightfly |
last post by:
Ok, I know all about how binary numbers translate into text characters.
My question is what exactly IS a text character? Is it a bitmap?
|
by: richardkreidl |
last post by:
I have the following hash script that I use to compare two text files.
'Class
Public Class FileComparison
Public Class FileComparisonException
Public Enum ExceptionType
U 'Unknown
A 'Add...
|
by: Frustrated Developer via DotNetMonster.com |
last post by:
I have posted a couple times on here already and found the user community to
be very helpful. I took on a project before I realized how difficult a time
I'm having working with a database....
|
by: joelagnel |
last post by:
hi friends,
i've been having this confusion for about a year, i want to know the
exact difference between text and binary files.
using the fwrite function in c, i wrote 2 bytes of integers in...
|
by: list |
last post by:
Hi folks,
I am new to Googlegroups. I asked my questions at other forums, since
now.
I have an important question: I have to check files if they are
binary(.bmp, .avi, .jpg) or text(.txt,...
|
by: Xah Lee |
last post by:
Text Processing with Emacs Lisp
Xah Lee, 2007-10-29
This page gives a outline of how to use emacs lisp to do text
processing, using a specific real-world problem as example. If you
don't know...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |