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

  • Home
  • SEARCH
  • 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 7800901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:47:10+00:00 2026-06-02T00:47:10+00:00

I have active_record setup to use a Postgresql database. One of the columns is

  • 0

I have active_record setup to use a Postgresql database. One of the columns is a character varying[] (basically a varchar array).

Anyway, my import routine then reads a tab-delimited text file and inserts records. All is fine until I get to an array. The column that should be converted to an array is comma separated. But the line itself is tab separated.

A sample of the data I’m importing looks like (tab delimited):

Col1      Col2     Col3                  Col4
----------------------------------------------
Apple     Pear     Sweet,Round,Green     Fruit

Col3 is imported like (ruby): col3.split(/,/) which gives me an array in Ruby. But active_record bombs out with:

PG::Error: ERROR: array value must start with “{” or dimension information (ActiveRecord::StatementInvalid)

How can I insert that column correctly?
Also, sometimes, col3 will be NULL.

  • 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-02T00:47:11+00:00Added an answer on June 2, 2026 at 12:47 am

    I was able to insert using the following Ruby code:

    alternatenames = '{' + s[3].split(/,/).map {|n| '"' + n + '"'}.join(",") + '}'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use PostgreSQL locally since I have to use it on Heroku.
I have a system setup where users can post microposts (basically status updates) and
I have a non-rails application that I want to use rails active-record migrations with.
I have an ActiveRecord model whose fields mostly come from the database. There are
I have an MVC project setup, and I've brought the subsonic Active Record templates
I have a event model that has many invitations. Invitations are setup through checkboxes
I currently have 2 models setup: class Topic < ActiveRecord::Base belongs_to :category end class
I have setup a model structure which allows different models to associate with a
I have managed to setup autocomplete field for my rails app. What I'm trying
I would like to use JRuby to run a script which populates a database.

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.