Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8586617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:21:07+00:00 2026-06-11T22:21:07+00:00

I am provided with text files containing data that I need to load into

  • 0

I am provided with text files containing data that I need to load into a postgres database.

The files are structured in records (one per line) with fields separated by a tilde (~). Unfortunately it happens that every now and then a field content will include a tilde.

As the files are not tidy CSV, and the tilde’s not escaped, this results in records containing too many fields, which cause the database to throw an exception and stop loading.

I know what the record should look like (text, integer, float fields).

Does anyone have suggestions on how to fix the overlong records? I code in per but I am happy with suggestions in python, javascript, plain english.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:21:08+00:00Added an answer on June 11, 2026 at 10:21 pm

    You could try to filter out the corrupted lines with something like:

    perl -F'~' -lane 'print if @F > 10' input.txt > broken_fields.txt 
    

    (Assuming your max number of fields is 10). It will give you a short(er) file with suspect lines that you could perhaps inspect manually. This will not be a foolproof filter, it will for example print out allowed fields, such as tildes inside quoted strings. If you want something more exact, you can use Text::CSV, but that will present other difficulties when it comes to broken csv data.

    There might be a better (and automatic) way to solve this, but without knowing what your input looks like, there is no way to really recommend something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some txt files that contain tables with a mix of different records
Is anyone using the built-in code generation provided via text templates (using .tt files)?
I'm trying to parse thousands of spec sheet text files containing company, material, chemical
I need to pass some text files, uploaded from a Wt file upload widget,
I'm writing an application where i need to determine if the files provided from
I need to assign a character array containing 300000 data which are fetched from
Is there a text equivalent of CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol provided as a property in C#. e.g.
I want to insert given text to existing pdf at X,Y location provided. I
I have Text( http://www.mywebsite.com ) in a view, in which i need to provide
My web designer has provided me with updated fonts/icons that have been added to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.