Need Python For Converting Data Format

Mar 26, 2014

The below is the existing data in a file running over 24768 lines

There are duplicate names link (abc) , width and FLof which stands for offset

file A
------------------
###########################################################################
# F Name Gro Width FLof Class
###########################################################################
1cbb abc - 6 2 INDIRECT
1cbc xyz - 3 0 INDIRECT
1cbd abc - 4 0 INDIRECT
1cf3 bcd - 3 5 INDIRECT
1cf4 pqr - 3 0 INDIRECT
1cf5 bcd - 8 0 INDIRECT
---------
---------- so on

I want a script to convert the file data to as folowing data :

file B
-----------------
###########################################################################
# F Name Gro Width FLof Class
###########################################################################
1cbb abc_7_2 - 6 2 INDIRECT
1cbc xyz - 3 0 INDIRECT
1cbd abc_11_8 - 4 0 INDIRECT
1cf3 bcd_7_5 - 3 5 INDIRECT
1cf4 pqr - 3 0 INDIRECT
1cf5 bcd_15_8 - 8 0 INDIRECT

Explanation for conversion is here :

first row abc has width as 6 and FLof as 2 in file A, so it occupies position 2,3,4,5,6,7 accounting to 6 position so represented as abc_7_2 in file B

Now row three of file A has duplicate of abc so now the new offset will be previous offset plus one ie. position will start from 8 and it goes as follows 8,9,10,11 so represented as abc_11_8

This will create unique and informative names, the same goes with other rows :

</pre> mh_sh_highlight_all('xml');

View Replies


ADVERTISEMENT

Converting Python To JavaScript

Mar 16, 2014

I am taking Python this semester. Our teacher wants us to convert Python to JavaScript without really explaining how or/and expecting us to be familiar with it already.Python Program I have is pretty simple - it prompts you to enter your first and last name and end your DNA string, "CAG" repeats are counted by another function and the result is passed to function that identified weather you may have huntington's decease or not.

<body>
<p>Enter First Name: <input type="text" size="25" id="firstname" value="">
<p>Enter Last Name: <input type="text" size="25" id="lastname" value="">
<p>Enter DNA: <input type="text" size="25" id="DNA" value="" >
<p><button onclick="alertt(f,l,d,c,p)" style="background-color:pink"><b>PRESS TO FIND OUT RESULT</b></button></p>
<script>

[code]...

When I run it there is an issue with countCAG and prediction functions :( I would run each one individually in JS console and I get Undefined, or InvalidString I read that I am supposed to use var in front of each variable, unlike in Python where you just assign variable a value without any add-ons in the front. But JS console seems to recognize both ways of assigning, however var smth=0 immediately evaluates to Undefined, and smth=0, gives me 0...

View Replies View Related

Reading Data From Socket / Responses Of Python Server

Nov 3, 2014

I'm having a lot of problems reading data from a socket. I'm trying to read the responses of a python server. I've a

BufferedReader inputStream = new BufferedReader( new InputStreamReader(socket.getInputStream()));

And then:

char[] messageChunk=new char[32768]; //32768
List<Byte> messageBytesList = new ArrayList<Byte>();
while (inputStream.ready()) {
inputStream.read(messageChunk, 0, 32768);
for(int k=0;k<32768;k++){
messageBytesList.add((byte)messageChunk[k]);
}
}

inside a thread. Then I convert the list of bytes to a byte array using:

Byte[] messageBytes = messageBytesList.toArray(new Byte[messageBytesList.size()]);
byte[] message = ArrayUtils.toPrimitive(messageBytes);

The problem is that I often receive ArrayOutOfBound errors when I try to parse the byte array. I think that I'm reading from the socket in a wrong way..

View Replies View Related

Converting HGT Files To Proprietary Format

Sep 16, 2014

I have to read SRTM .hgt binary files in Java and then rewrite them in a binary proprietary format. The format is to write the .hgt file as 2-dimensional binary array of either 1 byte, 2 byte, 3 byte or 4 byte integers in BIG ENDIAN format. I have chosen short as the data type(2 bytes) because I believe the data in the .hgt file has the maximum value of 32767. I am enclosing the code here - how do I read the data into 2-dimensional array ?

Java Code:

FileChannel fileInputChannel = new FileInputStream(fileInput).getChannel();
FileChannel fileOutputChannel = new FileOutputStream(fileOutput).getChannel();
int size = (int)fileInputChannel.size();

[code]....

View Replies View Related

How To Escape unwanted Special Characters In String Data While Converting Into XML Data

Mar 7, 2014

I'am trying to converting string data into xml data using xml beans and StringEscapeUtils.This is work fine but in one case it if the data contains special characters.
  
Code snippet
--------------------
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
public class ParseXMLData { 
    public static XmlObject parseXML(String stringXML) {
        XmlObject xmlObject = null;

[Code] ....
 
success case
---------------------------
i/p------<aaa><bbb>This converts string to xml</bbb></aaa>
o/p---<aaa><bbb>This converts string to xml</bbb></aaa>
 
Failer case
-----------------
i/p----<aaa><bbb>This fails if it contains < symbols</bbb></aaa>
expected o/p----<aaa><bbb>This fails if it contains < symbols</bbb></aaa>
 
Observed that it converts < to '<' but  as per xml rules, if data contains '< ' it fails. I want to convert staring and end tags to xml format and if data in b/w middle of starting and ending tags do'n need to convert it. How to do it.

View Replies View Related

Reading Tabular Format Data From PDF File

Feb 20, 2015

I am working on a project where as an input I need to read to data from PDF.

The PDF data will look like

As shown below:

Serial NoName of bookQuanity of BooksLibrary NamePrice

1aaa1London

2bb2Newyork

3cc1Paris

Total number of books4

Payment info

The number of books are dynamic in every pdf which I am going to receive.

View Replies View Related

Value Format While Reading Excel Data Into Java

Jan 20, 2015

I am reading Excel data using java apache. I got format issue while reading double value such as 869.87929 (in excel) into 869.8792899999999 (in java).

I'm using following files to read excel data.

1. Schema.csv: SheetName,2-int-Double
2. File.xls:

col1 | col2
123 | 869.87929

Sample code:

if(type.equals("Double")){
String str = content[i-1];
//System.out.println(str);
BigDecimal d = new BigDecimal(str);
listObjects.add(d);
}

Note: type from schema.csv & content [] value from file.xls
If I print **str**, it shows value as 869.8792899999999.
But i need to get **str** value as 869.87929. How can I get it?

View Replies View Related

Converting Primitive Data Types To Read Integers With Decimal

Sep 13, 2014

I get an error when I try to divide 500 miles by 25.5 gallons

Exception in thread "main" java.lang.NumberFormatException: For input string: "25.5"
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at Mileage.main(Mileage.java:42)
Java Result: 1

[Code] .....

View Replies View Related

How To Get Date Data Type From MySQL To Java Format

May 22, 2012

In my project i am facing an problem, The My SQL Data base will accept the date format of yyyy/mm/dd only as "Date" data type but in my program i wants to use dd/mm/yyyy format. (i have this same format now) that's why I am unable to insert / retrieve it..

View Replies View Related

I/O / Streams :: POI - Log File To XLSX / Writing Data In Unreadable Format

Jul 16, 2014

When I am trying to read data from BufferedReader and writing into excel using FileOutputStream object with POI APIs then i am getting the data in excel file in bad formats. you can check the log file and excel file attached for more information.

Here my problem is I cannot use BufferedWriter in place of FileOutputStream because POI class XSSFWorkbook only have one write method and we can only pass FileOutputStream class object there.

public void readFile()throws IOException {
BufferedReader inputStream = null;
FileInputStream fis=null;
InputStreamReader isr = null;
//Blank workbook
XSSFWorkbook workbook = new XSSFWorkbook();

[Code] .....

View Replies View Related

Read Date From File / Calculate And Then Displays That Data In Table Format On Screen

Apr 22, 2015

The intent of the code is to read date from a file, does calculation and then displays that data in a table format on the screen. Then creates another file with those values:

Reads file: Beginningbalance.txt
Displays Data with calculation
Creates a file called "Newbalance.txt" with the following values:

111
251.41
222
402.00

With the way the code is written I can get it to create the file but it only displays one of the customers (111). I know that I need to create a loop but I am not sure how to build that. I tried creating another while loop and changing it to outFile but that was without success.

import java.io.*;
import java.util.Scanner;
import java.text.DecimalFormat;
public class Output {
public static void main(String[]args) throws IOException {

[Code] .....

View Replies View Related

Converting Excel Vba

Nov 3, 2014

I'm very new to Java and looking to expand knowledge base from Excel VBA..I'm looking to add or analyse data from a csv file in a time order fashion. i.e i want to keep/ add a cumulative total. (once i've achieved that i then want to look at a java equivalent of sumif...

View Replies View Related

JSP :: Converting ASP To Java

Dec 22, 2014

I'm converting from ASP to Java for a legacy site. I believe the first part of the if statement is right but I'm having an issue within the else staetment. I'm getting date is undefined, I've tried using getYear and getDate but have not been successful.

ASP:

If Request("action") = "results" Then
aMonth = Request("selMonth")
aDate = cint(Request("selDate"))
aYear = cint(Request("selYear"))
Else
aMonth = UCase(MonthName(Month(Date()),true))
aDate = Day(DateAdd("d",-1,date()))
aYear = Year(Date())
End If

[code]....

View Replies View Related

Converting Hex To ASCII

May 16, 2014

I try to use below codes to convert Hex String "1111737999630745" to ASCII.

When I read the result in Notepad++ with HEX-Editor plugin, I find attached image which is different from above String, there is one additional c2 and I am quite confused.

Java Code:

public static void main(String[] args) throws IOException {
Test strToHex = new Test();
File file = new File("D:/filename");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();

[Code] .....

View Replies View Related

Converting Int To A Char

Mar 3, 2015

I was reading about the char data type in Java. I know that an unsigned 16 bit integer is used to represent a char. So we can write the assignments below:

char a = 65; // a will get the value 'A'

But the limit of the char value is 65535.

So I've tried out a few things with char and trying to understand them but I'm not sure how they work.

char a =(char) 70000;
char b = (char) -1;

In the first case I thought that 70000 % 65535 would happen internally and the unicode character present at that location would get stored in 'a' but if I do that I get the answer of 70000 % 65535 as 4465. But when I display 'a' it shows me the output as '?'. Clearly '?' isn't at 4465.

In the second case I have no clue what's happening but somehow when I display 'b' it shows me '?' again.

View Replies View Related

Servlets :: How Does Multipart / Form-data Send Data Over Network During File Upload

Apr 9, 2015

I would like to understand how does multipart/form-data works during file upload scenario's, Does it chunks the data from client to server while transferring the files ?

View Replies View Related

How To Get Data Button To Display User Inputted (numbers) To Data Label

May 25, 2014

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayFinal_Panel extends JPanel {
private JLabel label1, label2, label3;
private JTextField box;

[code]....

I only want Listener 1 to work right now. Also, user input is in TextField.

View Replies View Related

Enterprise JavaBeans :: How To Refresh JPA Data When Table Data Is Updated From Backend

Nov 27, 2012

Is there a way to inform the Entity Manager or force the JPA provider to reload data from the database? The scenario could be data being updated by a store procedure or direct SQLPlus maintenance, without restarting the Application Server, the JPA need to load the newly updated data from the database.

I think the current JPA API is not enough. The void refresh(java.lang.Object entity) from EntityManager need to pass in the Entity object, I will like to know how to refresh the entire JPA Entity data after the physical table data being update from backend.

View Replies View Related

User Input All Of Data On A Single Line And Implement StringTokenizer To Assign That Data To File

Mar 21, 2015

By using FileReader, FileWriter and their constituents, I am creating a file to contain employee information ( name, age, hours, etc. ). The user is to input all of the data on a single line and we were asked to implement StringTokenizer to assign that data to the file. I have never used the StringTokenizer before, but I have a rough idea how it is to function. I used pw.println to test what I have so far, now I would like to let the user build the initial file with the "first employees" of the company, and then view the file, and then go back and append new employee data to that same file. My question is, how can I take the user input as a StringTokenizer and add that to the file?

In the for loop below, I thought I would see if it would work, but it does not. The loop only executes once and does not allow me to enter data.

public class Records {
public static void main(String [] args) throws IOException {
Scanner input = new Scanner(System.in);
FileWriter fw = new FileWriter("dbs3.java");
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
System.out.println("NEW EMPLOYEE DATA SHEET");
System.out.print("Number of new employees: ");
int number = input.nextInt();

[Code] ....

View Replies View Related

Converting Input From Textbox Into Int?

Apr 8, 2015

Here is my code, basically I'll tell you what my program is suppose to do, I want to be able to leave the text box's empty if I like I want to skip 1 or more or all if I like skipping just basically means 0 but getting this error, it's forcing me to type in them all.

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unk nown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at StockControl.addToStock(StockControl.java:86)

[Code] .....

My code :

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
 
[Code] .....

View Replies View Related

Converting Into Unicode Using Java

Jan 28, 2014

This is the code to convert string into unicode but I get an error as "illegal start of an expresssion"while running the code..

import java.util.Scanner;
import java.lang.String;
import java.lang.Character;
public class A
{
public static void main(String args[])
{

[Code]...

View Replies View Related

Converting Boolean Into String

Feb 15, 2014

I have this project due and its asking that i print out what type of triangle it is when the user inputs 3 sides. I have most of it done and working, but it pops up different windows instead of using one window for everything. The assignment says it needs all the final info to be in one window. The boolean is coming from another method. I'm unsure how to get it into a string (Or if that's what i have to do). The method must return a boolean true/false.

import javax.swing.*; 
public class Triangle { 
public static void main(String[] args) {
int side1 = getSides();
int side2 = getSides();
int side3 = getSides();
 
[Code] ....

View Replies View Related

Converting Char To Uppercase?

Jan 21, 2015

I'm trying to write something to will convert my Scanner input which will be either a string or a char toUpperCase but it is not working.
 
import java.io.File;
import java.util.Scanner; 
public class UpperCase {
 public static void main(String [] args) { 
Scanner kb = new Scanner(System.in);
char reply;

[code]....

View Replies View Related

Converting String To Animal?

May 21, 2014

In my Java class, the last assignment we had to turn in was to create a program that would take a users input and create a new type of animal. I went through the different steps in the instructions, and everything seemed to be going well up until the point where we actually took the users input and created the new animal. Specifically, I kept getting an error stating that I could convert a String to an animal.

I'm attaching the main class (Animal), one of my animal classes (Bird) and the class where I'm getting the error (AnimalStuff). I turned the program in as is, so what's done is done, but I'd like to learn what I'm doing wrong and what I can do better. I do know that the loop in AnimalStuff is wrong as it doesn't work right either, but I'm more concerned about the conversion from String to animal, as the entire program depended on this to work, and it doesn't.

public class Animal {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
}
public static String kind;
public static String integument;

[code]....

Is there anything that jumps out at to what I'm doing absolutely wrong?

View Replies View Related

Converting A String To Integer?

Sep 24, 2014

I've started writing a new program that Scans for some strings. I want to specify a random Integer to those Strings in order to do my desired idea. what should I do?!! my codes are here :

import java.util.Random;
import java.util.Scanner;
public class Draw {
public static void main(String[] args) {
System.out.println("This Program is written to solve little problems in families cause of doing unwanted works!!");

[code].....

now I want to Specify an Integer to each person that has been scanned! for example if the first person is " David " , which is a String, in the next step :

Random randomNumber = new Random();
randomNumber.NextInt(101);
int David = randomNumber.NextInt(101);

I want to what should I do?

View Replies View Related

Converting A Program Into Applet?

Sep 30, 2014

how to make an applet out of this program but can't seem to do it.

Java Code: import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JLabel;
import javax.swing.JFrame;
import java.io.*;
import java.util.Scanner;

[code]....

Technically, when you run the program, a gif page appears (that I put as a placeholder) and when you press the letter 'n' JCreator runs the program, displaying a character P on a .txt field made using the Notepad on Windows. You can move it left, right, down, and up andf it will move accordinly. However, each time I make such action, the compiler has to rewrite to whole .txt field with the new position.

My former tutor said that in order for it to be "real-time", we have to use an applet.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved