Giter Club home page Giter Club logo

Comments (4)

cstich avatar cstich commented on July 17, 2024

The import/export options of the script are mainly there to convert between different types of input files if you want to do that, so it doesn't make a lot of sense to go from CSV to CSV file. The script options are not particularly useful from an end-user perspective, but they make it relatively painless to ship with the most up-to-date version of the timezone map (which reminds me that I have to update that), and see whether you broke anything before you commit.

I am not a 100% sure I understand what you exactly want to do, but if you could elaborate a bit that would be great. I feel like I am now the one that is missing something obvious :)

You don't want to export polygons with timezone information by any chance?

from pytzwhere.

josiekre avatar josiekre commented on July 17, 2024

I simply need an offline way to append local time to a csv file with
lat/lon/timestamp (UTC). (Actually in my case it's a bunch of csv files at
once so I use glob.) I am doing analysis in R, and so in/out csv means I
can call it from R with 'system(python tzwhere.py)' and then call
'read_csv()" again easily to get the results back in. I've done a quick and
dirty implementation like so:

from tzwhere import tzwhere
import glob
import pandas as pd

def reader(f):
  d = pd.read_csv(f, names=['id', 'latitude', 'longitude', 'timestamp'])
  return d


def main():
  files = glob.glob('*.csv')
  data = pd.concat([reader(f) for f in files], ignore_index=True)
  tz = tzwhere.tzwhere(shapely=True)
  data['local_tz'] = data.apply(lambda row: tz.tzNameAt(row['latitude'],
                                                row['longitude']), axis=1)

  data.to_csv('to_r.csv', index=False)

if __name__ == "__main__":
  main()

---------- Forwarded message ----------
From: cstich [email protected]
Date: Tue, Nov 17, 2015 at 6:34 PM
Subject: Re: [pytzwhere] Why can't one read and write both csv's? (#30)
To: pegler/pytzwhere [email protected]
Cc: Josie Kressner [email protected]

The import/export options of the script are mainly there to convert between
different types of input files if you want to do that, so it doesn't make a
lot of sense to go from CSV to CSV file. The script options are not
particularly useful from an end-user perspective, but they make it
relatively painless to ship with the most up-to-date version of the
timezone map (which reminds me that I have to update that), and see whether
you broke anything before you commit.

I am not a 100% sure I understand what you exactly want to do, but if you
could elaborate a bit that would be great. I feel like I am now the one
that is missing something obvious :)

You don't want to export polygons with timezone information by any chance?

β€”
Reply to this email directly or view it on GitHub
#30 (comment).

from pytzwhere.

cstich avatar cstich commented on July 17, 2024

Your code makes sense to me as it is. Pandas is probably a much better choice for doing all the reading and writing of CSV files than using anything in pytzwhere for that. Does that answer your original question?

from pytzwhere.

josiekre avatar josiekre commented on July 17, 2024

Sure thing. I'll continue to use the script with pandas.

from pytzwhere.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.