Posts

Showing posts with the label list

Java one file to anothe file appending

I have two data file Test1 and Test2. Test1 datas: Test2.txt test4.txt(Output file) My code: The output I get is something like that: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 17.0] But the remaining columns are not there in my output. I take the 1st Columns of both file as my key attribute and insert element depending upon there ordering. What should I do to get my desire output? I would create a class to keep your data in. Something like: You can then keep an ArrayList, reading one lines values into one MyData object. You could then use Collections.sort(that arraylist) to sort it, and then iterate over it and print it to your file. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Sum attributes of duplicate coordinates in python

I am going through my coordinates data and I see some duplicate coordinates with different parameters due to certain preprocessing. I want to be able to merge the attributes corresponding to the matched coordinates and get the simplified results. To clarify what I mean here is an example: The above data is read as follows: point (1.0, 8.0) has a value of 13 and (2.0, 3.0) has a value of 16. Notice that the second point and fourth point have the same coordinates but different attribute values. I want to be able to remove the duplicates from the lists of coordinates and sum the attributes so the results would be new lists: 24 is the sum of 16 and 8 from the second and fourth points with the same coordinates, therefore one point is kept and the values are summed. I am not sure how to do this, I thought of using nested for loops of zips of the coordinates but I am not sure how to formulate it to sum the attributes. Any help is appreciated! I think that maintaining 3 lists is a bit awkward....