Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Offline mode for consultation #35

Closed
teolemon opened this issue Oct 22, 2017 · 11 comments
Closed

Offline mode for consultation #35

teolemon opened this issue Oct 22, 2017 · 11 comments
Assignees
Labels
Milestone

Comments

@teolemon
Copy link
Member

  • Download from the server, and store a reduced version (60MB) of Open Food Facts on the device.
  • Read from this version when offline, go back to the API when online
  • Offer to refresh the database in the settings
  • Offer to refresh automatically when on wifi
@teolemon
Copy link
Member Author

Blocked on the definition of a common standard for Android and iOS. A test version of the base has already been made.

@aleene
Copy link
Collaborator

aleene commented Oct 22, 2017

Is it possible to get the database for specific countries? What does reuced mean?

@teolemon
Copy link
Member Author

wget "https://world.openfoodfacts.org/data/en.openfoodfacts.org.products.csv"
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function
import csv
from itertools import imap
from operator import itemgetter


def main():
    #delimiter = '	'
    #with open('en.openfoodfacts.org.products.csv', 'rU') as input_file:
        #reader = csv.reader(input_file, dialect=csv.excel_tab)
        #filebu = open(input_file, 'rU')
        #reader = csv.reader(input_file, dialect=csv.excel_tab)
        #with open('output.csv', 'wb') as output_file:
            #writer = csv.writer(output_file, delimiter=delimiter)
    import pandas
    df = pandas.read_csv('en.openfoodfacts.org.products.csv', sep='\t', low_memory=False)
    colnames = ['code','product_name', 'generic_name', 'quantity', 'brands', 'ingredients_text', 'allergens', 'traces', 'nutrition_grade_fr']
   #data = pandas.read_csv('en.openfoodfacts.org.products.csv', sep='\t', low_memory=False, names=colnames)
    #data.to_csv('output-small.csv', sep='\t', encoding='utf-8')
    df.to_csv('output-small.csv', columns = colnames)

            #, 34, 53
if __name__ == '__main__':
    main()

@teolemon
Copy link
Member Author

output-small= 78,3 Mo for the whole world. Might have increased since 24.05.2017

@teolemon
Copy link
Member Author

https://world.openfoodfacts.org/data/output-small.csv
Database at 1GO, new export: 87MB

@aleene
Copy link
Collaborator

aleene commented Oct 29, 2017

Very nice. Wonder how I can use this to enhance the app.

@teolemon
Copy link
Member Author

Zipped, it goes down to 20MB for download.
If no connection is detected, fill the fields with an icon Not available offline and fill the values when you have them ?

@tovkal tovkal added the feature label Dec 2, 2017
@tovkal tovkal added this to the 1.0 milestone Dec 2, 2017
@joshuadeguzman
Copy link

Mind if i ask, should we consider downloading products by category / certain specifics (parameters) or should it really be downloaded as a whole compressed data when there is no internet connection?

@rudrankriyam rudrankriyam self-assigned this May 4, 2018
@rudrankriyam rudrankriyam added the GSoC 2019 Potential tasks - Summer of Code 2019 label May 4, 2018
@rudrankriyam rudrankriyam removed their assignment Jan 20, 2019
@teolemon teolemon removed the GSoC 2019 Potential tasks - Summer of Code 2019 label Mar 2, 2019
@teolemon
Copy link
Member Author

teolemon commented Mar 2, 2019

Please note that some of the info above is obsolete. We have new files.

@teolemon
Copy link
Member Author

teolemon commented Mar 2, 2019

I've created a special excerpt of the database, which has the required data to scan products for France. This is 11 Mb zipped, and 37Mb unzipped.
http://fr.openfoodfacts.org/data/offline/fr.openfoodfacts.org.products.small.csv.tgz

@teolemon
Copy link
Member Author

teolemon commented Mar 4, 2019

I have fixed the CSV export for NOVA which wasn't exported correctly:
https://world.openfoodfacts.org/data/offline/en.openfoodfacts.org.products.small.csv.zip

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants