## Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python

Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python
# 1
04-04-2014
Reducing the decimal points of numbers (3d coordinates) in a file; how to input data to e.g. Python

I have a file full of coordinates of the form:

The numbers don't always have the same number of decimal points. I need to reduce the decimal points of all the numbers (there are 128 rows of 3 numbers) to 2.

I have tried to do this using Python but keep encountering obstacles when trying to use simple scripts I've found online surrounding the conversion/interpretation of the file itself. I don't seem to be able to input the numbers in the file as floats, or list(s) thereof.

I don't really want someone to write something for me; I'd like to try to understand the principle behind what it is I need to do, as a beginner to the language. Any help would be greatly appreciated.

Last edited by bartus11; 04-04-2014 at 12:16 PM.. Reason: Please use [code][/code] tags.
 crunchgargoyle View Public Profile for crunchgargoyle Find all posts by crunchgargoyle
# 2
04-04-2014
Try:
This User Gave Thanks to bartus11 For This Post:
 bartus11 View Public Profile for bartus11 Find all posts by bartus11
# 3
04-04-2014
Thank you, that actually worked flawlessly. I think I can understand what's going on, as well.

Much appreciated.
 crunchgargoyle View Public Profile for crunchgargoyle Find all posts by crunchgargoyle

Test Your Knowledge in Computers #426
Difficulty: Medium
JavaScript uses prototypes where many other object-oriented languages use classes for inheritance.
True or False?

## Read a file with decimal numbers in bash

Hello, I have the following script while read id fraction do sambamba -h -f bam -t 10 --subsampling-seed=50 -s \$frac \${id}.bam -o \${id}.out.bam done < fraction.txt where fraction.txt has two columns (id,fraction) and 50 rows I am unable to run this as bash is not able to read the second...

## Add coordinates to line of output extracted from input file

I am trying to compare/confirm the output of an script using the perl below, which does execute. However I can not seem to print \$1 and \$2 in each line of the input separated by a tab in each line of the output. The input file is quite large so I have only included a portion, but the format is the...

## Grep commands for numbers w/decimal points

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Is there a grep commands for numbers w/decimal points Display lines for students with GPA above 3.69 but less...

## Reducing input file size after pattern search

I have a very large file with millions of entries identified by @M. I am using the following script to "extract" entries based on specific strings/patterns: #!/bin/bash if ] then file=\$1 else echo "Input_file passed as an argument \$1 is NOT found." exit; fi MID=(NULL "string-1"...

## Help with decimal points

Hi All, I would like to set decimal point to 16 in the following bash script but it has syntax error at }: awk '{printf"%.16e", (a<500,a++,\$1/(a*1.1212121212121229e-02))}' input.dat >output.datHow may I set it in the correct way please? Thank you very much!

## PL/SQL Determine if the coordinates of a point is within four points

Dear all, Given that the coordinates of 4 points such as c1(x1,y1), c2(x2,y2), c3(x3,y3), c4(x4,y4). Does any body know how to use plain sql / plsql to determine coordinates of a point e.g. (x,y) is within 4 points above efficiently. The 4 points supposedly form a rectangle rectangular. ...

## Determination n points between two coordinates

Hi guys. Can anyone tell me how to determine points between two coardinates. For example: Which type of command line gives me 50 points between (8, -5, 7) and (2, 6, 9) points Thanks

## Pulling data by GPS coordinates from text file

Hi there, I'm having a problem trying to extract data from within a text file. I'm trying to extract this manually for a lack of better words. I need any items that fall within latitude 36.5 to 39.5 and long -75.3 to -83.9 I have been doing this using cat neta.txt | grep '!38' and working...

## How to get data only inside polygon created by points which is part of whole data from file?

hiii, Help me out..i have a huge set of data stored in a file.This file has has 2 columns which is latitude & longitude of a region. Now i have a program which asks for the number of points & based on this number it asks the user to enter that latitude & longitude values which are in the same...

## searching for decimal numbers in a file

hi all, was wanting to know how to search for decimal numbers in a file ? am using solaris 8 and have tried a few options with "grep" but none of them seem to work. thanks in advance.