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 8023023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:26:28+00:00 2026-06-04T22:26:28+00:00

I would like to get data from a Mysql dump in yaml (PHPMyAdmin), but

  • 0

I would like to get data from a Mysql dump in yaml (PHPMyAdmin), but data are not surrounded by quotation mark.

I have zipcode that can start by 0 and after parsing I get decimal version of octal value, in place of simple string.

How can I do to force Yaml parser not to do auto-mapping, or just get all data as they are string ?

Thanks

== UPDATE ==

2185:
 id: 3274  
 civility: Mr  
 address: CROIX DES COMBES  
 zipcode: 04270
  • 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-04T22:26:30+00:00Added an answer on June 4, 2026 at 10:26 pm

    If your zipcode values are strings, which they probably should be in the database, and they are converted correctly to YAML, then they will be reconverted back into strings by Ruby’s YAML parser:

    require 'yaml'
    zip = '01234'
    

    If we treat it as a string, it converts correctly.

    zip.to_yaml # => "--- \"01234\"\n"
    YAML.load(zip.to_yaml) # => "01234"
    

    If we treat it as an integer, it has its leading 0 dropped, which I’d expect.

    zip.to_i.to_yaml # => "--- 1234\n"
    YAML.load(zip.to_i.to_yaml) # => 1234
    

    In your sample:

    zipcode: 04270
    

    zipcode is a YAML integer. It should be enclosed inside quotes to preserve its “stringness”.

    Wikipedia’s YAML article has a nice example showing how data types are supposed to be disambiguated.


    You can tweak all the instances of zipcode in the YAML before parsing it doing something like:

    require 'yaml'
    
    yaml_data = '2185:
     id: 3274  
     civility: Mr  
     address: CROIX DES COMBES  
     zipcode: 04270
    '
    
    yaml_data.gsub(/zipcode: (\d+)/, 'zipcode: "\1"') 
    # => "2185:\n id: 3274  \n civility: Mr  \n address: CROIX DES COMBES  \n zipcode: \"04270\"\n"
    
    YAML.load(yaml_data.gsub(/zipcode: (\d+)/, 'zipcode: "\1"')) 
    # => {2185=>{"id"=>3274, "civility"=>"Mr", "address"=>"CROIX DES COMBES", "zipcode"=>"04270"}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a trouble with CodeIgniter. I would like to get (recoup) data from
I would like to be able to get html-formatted data from mysql, and turn
I would like to get data using SNMP from a router. The data shall
I would like to know how to get data from preference activity when my
I have an SQL statement where I would like to get data of 1200
I'm a bit confused about displaying data from a MySQL database. I would like
I am pulling some data from mysql database using PHP, now I would like
I would like get all data into an object with request ajax. This data
I would like to get POST data sent to page controller in init() function
Given some arbitrary SQL I would like to get the data types of the

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.