I've got a csv file that I need to reformat using a perl script. I need to take the 14th and 16th positions and combine them together into one field with some characters. I'm still new to perl so I'm not sure the best practice. I was going to use a do loop and to get to the 14th "," value. Then read the chars up to the next ",". Skip the next comma value, then do the same for position 16.
I'm assuming there's a better way to do this.
5 4531 numberwhun 3,509
Recognized Expert Moderator Specialist
I've got a csv file that I need to reformat using a perl script. I need to take the 14th and 16th positions and combine them together into one field with some characters. I'm still new to perl so I'm not sure the best practice. I was going to use a do loop and to get to the 14th "," value. Then read the chars up to the next ",". Skip the next comma value, then do the same for position 16.
I'm assuming there's a better way to do this.
This being Perl, there is always TIMTOWTDI. That said, you could always use the DBI interface and include the DBD::CSV module which treats a CSV file as a database, allowing you easier access to each entry. I haven't used it, but read about it.
Regards,
Jeff
KevinADC 4,059
Recognized Expert Specialist
look into Text::CSV or Text::CSV_XS
You can find them on CPAN as well as other repositories: http://search.cpan.org/
Cool thanks. I'll check that out.
KevinADC 4,059
Recognized Expert Specialist
This being Perl, there is always TIMTOWTDI. That said, you could always use the DBI interface and include the DBD::CSV module which treats a CSV file as a database, allowing you easier access to each entry. I haven't used it, but read about it.
Regards,
Jeff
If a person is already familiar with SQL or their CSV file is structure as such, that is an option, interestingly, DBD::CSV module is a wrapper for Text::CSV_XS.
numberwhun 3,509
Recognized Expert Moderator Specialist
If a person is already familiar with SQL or their CSV file is structure as such, that is an option, interestingly, DBD::CSV module is a wrapper for Text::CSV_XS.
Oh, ok. Thanks! Wasn't aware.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frank Millman |
last post by:
Hi all
I need to generate potentially large reports from a database, and I
want to offer the option of print preview before actually printing
(using wxPython). I figure that the best way to...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: |
last post by:
In the beginning we had Ini files.
Later we had registery files.
Now have xml files and our read-only myapp.config file.
My question now, is what is the best way to store and load user and...
|
by: ESPN Lover |
last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one
way preferred over the other and why? Thanks.
using System;
using System.IO;
class Test
{
public static void...
|
by: jojobar |
last post by:
Hello,
I am trying to use vs.net 2005 to migrate a project originally in vs.net
2003. I started with creation of a "web site", and then created folders for
each component of the site.
I read...
| |
by: |
last post by:
I have an app that retrieves data from an Access database. At the moment I
have the SQL string as a Const in my app. I understand this is not best
practice. I don't want the user to have access to...
|
by: Tom |
last post by:
I am planning on adding a Preferences form to my application and using the
Property Grid to display the preferences to the user. What do you think
would be the best way to save these preferences...
|
by: gordon |
last post by:
Hi
I am looking to store some details about a user's configuration choices, in
particular the place where they have installed some data files, the OS that
they use, and their Windows user name. ...
|
by: TC |
last post by:
Hey All,
I have to read .csv files and display them in a DataGridView.
Currently, I'm dumping the data into a DataTable but it's causing problems
because the engine is automatically converting...
|
by: Brian |
last post by:
HI, I have two sets of data, the largest set of data contains 370 rows...
both sets only have two columns. I want to be able to distribute the data
with my applaction. The other option, would be...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |