<commit_before># (c) Fugro GeoServices. MIT licensed, see LICENSE.rst.
from django.core.management.base import BaseCommand
from ddsc_core.models.models import Location

import csv
from django.utils import timezone

from django.contrib.gis.geos import GEOSGeometry


class Command(BaseCommand):
    args = '<CSV file>'
    help = 'Imports a CSV file of locations into the database.'

    def handle(self, *args, **options):
        loc_latest = Location.objects.latest("pk")
        root_nodes = loc_latest.__class__.get_root_nodes()
        i = len(root_nodes) + 5
        count = 0
        maintain_list = []
        nr_0 = 0
        with open(args[0], 'rb') as f:
            reader = csv.reader(f)
            for row in reader:
                if len(row) >= 0:
                    uuid = row[0]
                    name = row[1]
                    x = row[2]
                    y = row[3]
                    z = row[4]
                    srid = row[5]
                    parentuuid = row[6]
                    if len(parentuuid) < 5:
                        maintain_list.append(0)
                        nr_0 += 1
                    else:
                        maintain_list.append(parentuuid)
                    description = row[9]
                    if row[10] is not '':
                        geometry_precision = row[10]
                    else:
                        geometry_precision = None
                    location_description = row[11]
                    if x is not '':
                        geo_input = 'POINT(' + x + ' ' + y + ' ' + z + ')'
                        point_geometry = GEOSGeometry(geo_input, int(srid))
                    else:
                        point_geometry = ''
                    Location.objects.create(name=name,
                        description=description,
                        geometry_precision=geometry_precision,
                        point_geometry=point_geometry,
                        real_geometry='',
                        depth=1,
                        numchild=0,
                        path='{0:04}'.format(i),
                        relative_location=location_description,
                        uuid=uuid, created=timezone.now())<commit_msg>fix of transformation from RDS<commit_after># (c) Fugro GeoServices. MIT licensed, see LICENSE.rst.
from django.core.management.base import BaseCommand
from ddsc_core.models.models import Location

import csv
from django.utils import timezone

from django.contrib.gis.geos import Point


class Command(BaseCommand):
    args = '<CSV file>'
    help = 'Imports a CSV file of locations into the database.'

    def handle(self, *args, **options):
        loc_latest = Location.objects.latest("pk")
        root_nodes = loc_latest.__class__.get_root_nodes()
        i = len(root_nodes) + 5
        count = 0
        maintain_list = []
        nr_0 = 0
        with open(args[0], 'rb') as f:
            reader = csv.reader(f)
            for row in reader:
                if len(row) >= 0:
                    uuid = row[0]
                    name = row[1]
                    x = row[2]
                    y = row[3]
                    z = row[4]
                    srid = row[5]
                    parentuuid = row[6]
                    if len(parentuuid) < 5:
                        maintain_list.append(0)
                        nr_0 += 1
                    else:
                        maintain_list.append(parentuuid)
                    description = row[9]
                    if row[10] is not '':
                        geometry_precision = row[10]
                    else:
                        geometry_precision = None
                    location_description = row[11]
                    if x is not '':
                        point_geometry = Point([float(x), float(y), float(z)], srid=int(srid))
                        if int(srid) != 4258:
                            point_geometry = point_geometry.transform(4258, clone=True)
                    else:
                        point_geometry = ''
                    Location.objects.create(name=name,
                        description=description,
                        geometry_precision=geometry_precision,
                        point_geometry=point_geometry,
                        real_geometry='',
                        depth=1,
                        numchild=0,
                        path='{0:04}'.format(i),
                        relative_location=location_description,
                        uuid=uuid, created=timezone.now())
{'fraction_non_alphanumeric': 0.08668122270742358, 'fraction_numerical': 0.014410480349344978, 'mean_word_length': 1.1803902903379344, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1880858', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1100, 'n_words': 268}