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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:20:00+00:00 2026-06-13T06:20:00+00:00

I need to get some meteorological data into a MySQL database. File inputFile.csv is

  • 0

I need to get some meteorological data into a MySQL database.
File inputFile.csv is a comma-delimited list of values. There are 241 lines and 481 values per line.
Each line maps to a certain latitude, and each value’s position within the line maps to a certain longitude.

There are two additional files with the same structure, lat.csv and lon.csv. These files contain the coordinates that the values in inputFile.csv map to.

So to find the latitude and longitude for a value in inputFile.csv, we need to refer to the values at the same line/position (or row/column) within lat.csv and lon.csv

I want to translate inputFile.csv using lat.csv and lon.csv such that my output file contains a list of values (from inputFile.csv),latitudes, and longitudes.

Here is a small visual example:

    inputFile.csv
    3,5,1,4,5
    1,4,1,2,5
    5,7,3,8,0

    lat.csv
    22,31,51,21,52
    55,21,24,66,12
    11,23,12,55,55

    lon.csv
    12,35,12,52,11
    35,11,25,33,42
    62,53,45,25,54


    output:
    val lat lon
    3   22  12
    5   31  35
    1   51  12
    4   21  52
    5   52  11 
    1   55  35
    4   21  11
    1   24  25  
    2   66  33
    etc

What is the best way to do this in python/numpy?

  • 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-13T06:20:01+00:00Added an answer on June 13, 2026 at 6:20 am

    I suppose that since you know the total size the the array that you want, you can preallocate it:

    a = np.empty((241*481,3))
    

    Now you can add the data:

    for i,fname in enumerate(('inputFile.csv','lat.csv','lon.csv')):
        with open(fname) as f:
            data = np.fromfile(f,sep=',')
            a[:,i] = data.ravel()
    

    If you don’t know the number of elements up front, you can generate a 2-d list instead (a list of np.ndarrays):

    alist = []
    for fname in ('inputFile.csv','lat.csv','lon.csv'):
        with open(fname) as f:
            data = np.fromfile(f,sep=',')
            alist.append( data.ravel() )
    a = np.array(alist).T
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get some data from a mysql database.I'm running a php script
I need to get some external data to form an output file name in
I have a very basic need to get some data from the database and
I'm working with some issue. I need to get some data from database 1)
I need to get some values of HTML web page. I want only the
I need to get some data from a column. For example I have data
I need to get some doubles from a string. string data = getMyData(); char**
i need to get some data somewhere to put in a timeline. the data
I have a table that I need to get some specific data from for
so I have multiple HTML files which I need to get some praticular data

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.