[Swlug] help with text manipulation

Mark Einon mark.einon at gmail.com
Thu Jun 21 08:37:39 UTC 2018


On Wed, 2018-06-20 at 23:06 +0100, bascule via Swlug wrote:
> On Wednesday, 20 June 2018 22:12:05 BST Mark Einon via Swlug wrote:
> > It's not that much effort - two lines of code, which I use on a
> > daily
> > basis. It took less than 3 mins to post.
> 
> well that's good:)
> however perhaps i should have been clearer in my initial post, my
> programming 
> skills are basically nill, the occasional one line bash script.
> i do not know what a gist is:) and the file i downloaded had lines
> about 
> kernels in it, which is kind of freaky.
> i have no idea what to do with your stuff/page.
> sorry about that, no one like to admit being a bit dumb but i think if
> i don't 
> do that now then this all gets very complicated very quickly.:)
> 
> i will just have to live with not being able to do what i wanted and
> moveon:) 
> it's not job related or anything.

Ah, apologies - I assumed that as you were playing with json, you might
be familiar with some of the things I was using. Please don't be put
off!

In which case, you should be able to paste this into a file, change the
in/out filenames as needed and run to get the job done (pasted in case
the attachment doesn't work, between dashes).

----
#! /bin/env python 
 
# Use pandas library 
import pandas as pd  
       
# Read in the json file 
dataframe = pd.read_json('input.json')

# Drop all duplicates where subset listed are identical
dataframe.drop_duplicates(subset=			
		['FormID','posX','posY','posZ','rotX','rotY','rotZ'])

# Write the results to another file 
dataframe.to_json('output.json', orient='records')
----

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bascules_json_dedup.py
Type: text/x-python
Size: 435 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/swlug/attachments/20180621/6fd2d420/attachment.py>


More information about the Swlug mailing list