# At the end of record in .txt file on server
I am reading a .txt file on server ..
Spliting the recoed at horizantal tab.
everything is fine but the # at the and of record is not getting eliminated.
I have tried with CR_LF and NEWLINE tooo ... no use....
I have to be able to delete this..
Hi Kalyan Mohan Venigalla,
if you open dataset in text mode and read dataset into <textvar or string>, the linefeeds should not be read but used to distinguish lines of (possible) different line length.
The # character just means non-displayable character. Depending on where the file comes from and how it was created and/or transfered to SAP server, this may be anything.
In debugger, you may switch to hex view and see what it is. Compare to the attributes of CL_ABAP_CHAR_UTILITIES and choose the right one for deletion or replacement.
Regards,
Clemens
Similar Messages
-
At the end each record in a file....
hi,
I want the output as follows:
1. 50501;2010-05-27 19:48:25;1;P002;127;
whihc means it should end with colon....
i am getting the output as
1. 50501;2010-05-27 19:48:25;1;P002;127
it s all correct but at the end i dont get a semi colon as i have used concatenate... sepoarated by semicolon...
can anyone tell me how do i change this... or what additions to be made??My first idea was to add a semicolon to the list of field to concatenate
CONCATENATE '1. 50501' '2010-05-27 19:48:25' '1' 'P002' '127' '' ';' INTO string SEPARATED BY ';'.
giving two semicolon at end, so i fear you have to add a
CONCATENATE string ';' INTO string.
Regards,
Raymond -
How to add spaces at the end of record
Hi Friends,
i am creating a file which contains more than 100 records.
In ABAP i have internal table with on field(135) type c.
some time record have length 120, somtime 130 its vary on each record.
but i would like to add space at the end of each record till 135 length.
Can you please help me how to add speace at the end of record.
regards
MalikSo why did you said that in your first posting? My glass sphere is out for cleaning...
Instead of type c use strings and add spaces until they have the appropriate length.
loop at outtab assigning <pout>.
while strlen( <pout>-val ) < 135.
concatenate <pout>-val `` into <pout>-val.
endwhile.
endloop. -
Determine the number of records in a file
I want to analyse record types from a large input file and so far have managed to extract different groups and created the relevant files. All I want to do now is count the number of records in each file so I can produce a report showing the different types but cannot figure out how to do this, I know it will be simple but I cannot get any command to accomplish this, help please!
in applescript, there are a few ways to count patterned text. if (as jeffrey suggests) each record is a separate line, then you can use the following:
set textContents to read "/path/to/file.txt"
count of paragraphs of textContents
if records are determined by some other process (such as a special delimiting character or phrase) you can use text items (replace the @ sign with the special character or phrase):
set textContents to read "/path/to/file.txt"
set {oldTID, my text item delimiters} to {my text item delimiters, "@"}
set theCount to count of text items of textContents
set my text item delimiters to oldTID -
How to keep the ending silence of a music file?
I am fed up...
iTunes just always clips the ending silence of all my music. This is SO annoying, if you i.e. listen to a classic piece of music, Beethoven, Bach etc. ALWAYS iTunes bombs in the next title on the playlist milliseconds after the previous title has ended.
I do not know, which "60 beats a second" kid has programmed such a senseless feature....?
Of course I browsed the Internet, of course I used the search function in this forum.
It seems really many people have the same problem, but the only solutions are like adding silent 2 seconds mp3 files into the playlist.
This iTunes is really not a very well programmed software, if users needs these awkward workarounds...
Is there any smart solution to this problem? Help is really appreciated.iTunes doesn't do anything with the "ending silence of a music file". If you have crossfading turned on (see previous comment) each track will start playing, with a predetermined fade in, before the previous one ends. You definitely want have that disabled. Otherwise, each track plays through to the end and the next one starts immediately - there is no "gap". However, you would normally expect that last few seconds of the track itself to be "silent" so that you hear a gap between each piece of music - just as you would when listening to a CD. Are you perceiving something different? There are a couple of somewhat obscure scenarios where the end of a track could be truncated. One involves a very specific error that could occur if your music has been imported from CD outside iTunes and then transferred to it - but that would require a very deliberate action with certain tools used for this purpose. In technical terms, the import ignores the "pre-gap" that may precede a track on a CD (you'd see this on some CD players as a brief - usually two second - countdown after the end of one track and before the start of the next. Most software, iTunes included, normally treats this pre-gap as part of the preceding track.
The other possibility is that the metadata associated with some tracks has been altered such that playback terminates before the actual end of the track. However, it requires a specific user action for this to happen - I can't think of a way it could happen accidentally.
Bottom line is that - unless you've hit one of these unlikely scenarios, or found a previously unreported bug (either in iTunes itself or in its interaction with audio drivers), or have that ghastly crossfade function turned on, you are hearing the music as recorded and mastered. The only other exception is the case where you are hearing the end of one album/disc immediately followed by the start of the next. Depending on how its been mastered, there could be a "shorter than expected" gap between them. -
How to read the last line in a txt file?
Dear all,
I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
Thank you very much!If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
import java.io.*;
import java.util.*;
public class GetLinesFromEndOfFile
static public class BackwardsFileInputStream extends InputStream
public BackwardsFileInputStream(File file) throws IOException
assert (file != null) && file.exists() && file.isFile() && file.canRead();
raf = new RandomAccessFile(file, "r");
currentPositionInFile = raf.length();
currentPositionInBuffer = 0;
public int read() throws IOException
if (currentPositionInFile <= 0)
return -1;
if (--currentPositionInBuffer < 0)
currentPositionInBuffer = buffer.length;
long startOfBlock = currentPositionInFile - buffer.length;
if (startOfBlock < 0)
currentPositionInBuffer = buffer.length + (int)startOfBlock;
startOfBlock = 0;
raf.seek(startOfBlock);
raf.readFully(buffer, 0, currentPositionInBuffer);
return read();
currentPositionInFile--;
return buffer[currentPositionInBuffer];
public void close() throws IOException
raf.close();
private final byte[] buffer = new byte[4096];
private final RandomAccessFile raf;
private long currentPositionInFile;
private int currentPositionInBuffer;
public static List<String> head(File file, int numberOfLinesToRead) throws IOException
return head(file, "ISO-8859-1" , numberOfLinesToRead);
public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
assert (file != null) && file.exists() && file.isFile() && file.canRead();
assert numberOfLinesToRead > 0;
assert encoding != null;
LinkedList<String> lines = new LinkedList<String>();
BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
lines.addLast(line);
reader.close();
return lines;
public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
return tail(file, "ISO-8859-1" , numberOfLinesToRead);
public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
assert (file != null) && file.exists() && file.isFile() && file.canRead();
assert numberOfLinesToRead > 0;
assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
LinkedList<String> lines = new LinkedList<String>();
BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
// Reverse the order of the characters in the string
char[] chars = line.toCharArray();
for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
char temp = chars[j];
chars[j] = chars[k];
chars[k]= temp;
lines.addFirst(new String(chars));
reader.close();
return lines;
public static void main(String[] args)
try
File file = new File("/usr/share/dict/words");
int n = 10;
System.out.println("Head of " + file);
int index = 0;
for (String line : head(file, n))
System.out.println(++index + "\t[" + line + "]");
System.out.println("Tail of " + file);
int index = 0;
for (String line : tail(file, "us-ascii", n))
System.out.println(++index + "\t[" + line + "]");
catch (Exception e)
e.printStackTrace();
}Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit). -
i am having problem when i am updating my iphone 4 to ios 5 ..it get update n took 50 minutes then at the end when it was processing file ...suddenly an error comes that an unknown error accurred {9006}..please help me..how will i update my iphone 4
Error 9006: Following Troubleshooting security software frequently resolves this error. There may be third-party software installed that modifies your default packet size in Windows by inserting a TcpWindowSize entry into your Registry. Your default packet size being set incorrectly can cause this error. Contact the manufacturer of the software that installed the packet size modification for assistance.
-
What is the best way to get the end of record from internal table?
Hi,
what is the best way to get the latest year and month ?
the end of record(KD00011001H 1110 2007 11)
Not KE00012002H, KA00012003H
any function for MBEWH table ?
MATNR BWKEY LFGJA LFMON
========================================
KE00012002H 1210 2005 12
KE00012002H 1210 2006 12
KA00012003H 1000 2006 12
KD00011001H 1110 2005 12
KD00011001H 1110 2006 12
KD00011001H 1110 2007 05
KD00011001H 1110 2007 08
KD00011001H 1110 2007 09
KD00011001H 1110 2007 10
KD00011001H 1110 2007 11
thank you
dennis
Edited by: ogawa Dennis on Jan 2, 2008 1:28 AM
Edited by: ogawa Dennis on Jan 2, 2008 1:33 AMHi dennis,
you can try this:
Sort <your internal_table MBEWH> BY lfgja DESCENDING lfmon DESCENDING.
Thanks
William Wilstroth -
CR & LF characters at the end of records when using delimited flat file (CR is missing)
Hi All,
I have a requirement where data of SQL query needs to be loaded to a CSV file.
The row delimiter of the CSV file has to be CR-LF.
In the flat file connection manager, I have mentioned Header Row delimiter as "{CR}{LF}" and under columns section, row delimiter is specified as "{CR}{LF}".
But when I open the detsnation CSV file using notepad++, I see only "LF" at the end of all rows.
Can you please let me know how can I get both CR & LF at the end of each row
Below is the screen shot of the flat file connection manager which I have used for CSV destination file:
RakshaHi Raksha,
Just as Vaibhav said, I’m curious why you need use “CR & LF” as row delimiter in Flat File Connection Manage. Since you can use "CR" as row delimiter in Flat File Connection Manager and it worked fine, you can directly specify "CR"
as row delimiter in Flat File Connection Manage.
Besides, if you still want to replace “LF” with “CR & LF” in the text file, we can use Notepad++’s Find/Replace feature or Edit -> EOL Conversion to achieve the goal. Then we can specify "CR & LF" as row delimiter in Flat File
Connection Manage.
The following blog about conversion between “LF” and “CR & LF” row delimiter in Notepad++ is for your reference:
http://sqlblog.com/blogs/jamie_thomson/archive/2012/08/07/replacing-crlf-with-lf-using-notepad.aspx
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
SQL Loader problem while loading records from txt file to database table.
I am getting following error while loading records from flat txt file into database table with the help of 'sqlldr' command. I have executed catldr.sql from RDBMS folder but it is still showing same error. I am setting DIRECT = TRUE while issuing sqlldr command. If I try with DIRECT = FALSE then it works fine. Database is Oracle 8i.
SQL*Loader-951: Error calling once/load initialization
ORA-24329: invalid character set identifier
F1 Please.Hello,
Direct path load, can only be used with SQL*Loader and Database have the same version.
Care to tell the database version and sql*loader version you are using.
-Sri -
Printing to the end of a Random Access file with FileOutputStream
I need to use FileOutputStream or anything else to print to a text file. However I need to print to the "end" of the file and not write over existing content. Anybody, given the following how would I append the file "myFile.txt"? The code below writes over existing data in the file.
import java.io.*
class FileOutputDemo
public static void mani( String argsv[])
FileOutputStream out;
PrintStream p;
try
out= new FileOutputStream("myFile.txt");
p=new PrintStream( out ) ;
p.println("Write this line of text to the end of the file");
p.close();
catch(Exception e) {*Do something */}One way is to use the RandomAccessFile class methods to append to the end of a file. Use the seek and length methods to go to the end of the file and use the appropriate method to write your data. Something like this:
try {
RandomAccessFile logFile=
new RandomAccessFile("myFile.txt", "rw");
logFile.seek(logFile.length());
logFile.writeBytes(
args[0]+"\n");
catch (Exception e) {
System.err.println("Error!");
HTH -
Hi
I need to know the command for getting list of softwares installed on all the remote systems in network which are existing in their respective registry like HKEY_LOCAL_MACHINE\SOFTWARE of all other systemsHey
Sorry this isn't powershell but it should do the job if you want to use it. The problem with using the Win32_Product WMI Class to enumerate the installed software (especially on Windows 2000 & 2003 Servers) is that the WMI class is NOT installed by default. Here is a VBScript i wrote to read a list of hostnames from a text file named "ComputerNames.txt" from the scripts directory and attempt to remotely enumerate all subkeys within the following registry key
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
For each subkey enumerated it will attempt to read the value of the "DisplayName" key and output the results to a csv file.
(the results should be the same as what you would see when you open Add/Remove Programs)
Hope that helps
Cheers
Matt :)
'Script Name : CheckInstalledSoftware.vbs
'Author : Matthew Beattie
'Created : 01/03/10
'Description : This script reads a list of hostnames from a text file name "ComputerNames.txt" in the scripts working
' : directory. For each hostName it requests an ICMP response and if successfull attempts a remote registry
' : connection to enumerate and read the registry values of installed software. All results are logged to the
' : scripts working directory in a log file per computer name.
'Initialization Section
Option Explicit
Const ForReading = 1
Const ForAppending = 8
Dim objFSO, wshNetwork, wshShell, hostName
Dim scriptBaseName, scriptPath, scriptLogPath
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject("WScript.Shell")
Set wshNetwork = CreateObject("WScript.Network")
scriptBaseName = objFSO.GetBaseName(Wscript.ScriptFullName)
scriptPath = objFSO.GetFile(Wscript.ScriptFullName).ParentFolder.Path
scriptLogPath = scriptPath & "\" & IsoDateString(Now)
If Err.Number <> 0 Then
Wscript.Quit
End If
On Error Goto 0
'Main Processing Section
On Error Resume Next
PromptStart
ProcessScript
If Err.Number <> 0 Then
Wscript.Quit
End If
PromptEnd
On Error Goto 0
'Functions Processing Section
'Name : ProcessScript -> Primary Function that controls all other script processing.
'Parameters : None ->
'Return : None ->
Function ProcessScript
Dim fileSpec, hostNames, regKey, keyName, results, result
keyName = "DisplayName"
regKey = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
fileSpec = scriptPath & "\ComputerNames.txt"
'Ensure the "ComputerNames.txt" file exists within the scripts working directory.
If Not objFSO.FileExists(fileSpec) Then
MsgBox DQ(fileSpec) & " does not exist!", vbCritical, scriptBaseName
Exit Function
End If
'Read the list of hostNames from the "ComputerNames.txt" text file within the scripts working directory.
If Not GetScriptInput(hostNames, fileSpec) Then
Exit Function
End If
'Attempt to read the registry from each hostname read from the list of hostnames.
For Each hostName In hostNames
Do
'Ensure the system responds to an ICMP request.
If Not CheckConnection(hostName) Then
LogMessage 2, "Failed to respond to an ICMP Request"
Exit Do
End If
'Enumerate and read the registry values.
If Not GetRegValues(results, hostName, keyName, regKey) Then
Exit Do
End If
'Log the registry values results.
For Each result In results
LogMessage 0, result
Next
Loop Until True
Next
End Function
'Name : GetScriptInput -> Reads a text file to be used as Script input.
'Parameters : items -> Output: An array of items in the script input file.
' : fileSpec -> The full folder Path, file Name and extention of the script input file.
'Return : GetScriptInput -> Returns an array of items for script input and True or False.
Function GetScriptInput(items, fileSpec)
Dim scriptInputFile, itemsDict, item
GetScriptInput = False
Set itemsDict = NewDictionary
If Not objFSO.FileExists(fileSpec) Then
Exit Function
End If
On Error Resume Next
Set scriptInputFile = objFSO.OpenTextFile(fileSpec, ForReading)
If Err.Number <> 0 Then
Exit Function
End If
On Error Goto 0
Do Until scriptInputFile.AtEndOfStream
item = scriptInputFile.ReadLine
If item = "" Then
Exit Function
End If
If Not itemsDict.Exists(item) Then
itemsDict.Add item, ""
End If
Loop
items = itemsDict.Keys
GetScriptInput = True
End Function
'Name : CheckConnection -> Checks a remote host using WMI ping.
'Parameters : hostName -> Hostname of computer system to verify network connectivity with.
'Return : Boolean -> True if hostname replies. False otherwise.
Function CheckConnection(hostName)
Dim ping, response, replied
Set ping = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & hostName & "'")
For each response in ping
replied = Not IsNull(response.StatusCode) And response.StatusCode = 0
Next
CheckConnection = replied
End Function
'Name : GetRegValues -> Enumerates the subkeys in a registry key and the values of the keyName.
'Parameters : hostName -> String containing the hostName of the system to enumerate the registry keys on.
' : keyName -> String containing the name of the registry key value to enumerate.
' : regKey -> Registry key to enumerate subkey names for.
'Return : GetRegValues -> Returns True and an Array containing the registry key values otherwise False.
Function GetRegValues(results, hostName, keyName, regKey)
Dim objReg, regDict, rootKey, hive, keyValue, subKeys, i
GetRegValues = False
rootKey = regKey
hive = GetRegistryHiveFromKey(rootKey)
On Error Resume Next
If hive <> 0 Then
'Create a dictionary object to store the registry values in.
Set regDict = NewDictionary
If Err.Number <> 0 Then
LogMessage 1, "Creating Dictionary Object"
Exit Function
End If
'Connect to the remote registry.
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & hostName & "\root\default:StdRegProv")
If Err.Number <> 0 Then
LogMessage 1, "Creating StdRegProv Object"
Exit Function
End If
'Enumerate the subkey names within the regKey paramater.
objReg.EnumKey hive, rootKey, subKeys
If Err.Number <> 0 Then
LogMessage 1, "Enumerating Registry Keys"
Exit Function
End If
'Ensure the results are an array.
If Not IsArray(subKeys) Then
subKeys = Array(subKeys)
End If
'Read the registry key value for each subkey. Add the results to the dictionary.
For i = 0 to UBound(subKeys)
objReg.GetStringValue hive, rootKey & "\" & subKeys(i), keyName, keyValue
If Err.Number = 0 Then
If Not IsNull(keyValue) Then
regDict(regDict.Count) = keyValue
End If
Else
Err.Clear
End If
Next
End If
On Error Goto 0
results = regDict.Items
GetRegValues = True
End Function
'Name : GetRegistryHiveFromKey -> Get the hive ID from a registry key name.
'Parameters: Input/Output: key -> Registry key name. Hive name will be removed.
'Return : GetRegistryHiveFromKey -> ID of hive of given key name (0 if invalid).
' : -> The hive name is removed from the input key name.
Function GetRegistryHiveFromKey (key)
Dim pos, hive
pos = Instr (key, "\")
If pos = 0 Then
pos = Len(key) + 1
End If
hive = Left (UCase (Left (key, pos - 1)) & " ", 4)
key = Mid (key, pos + 1)
GetRegistryHiveFromKey = Array(0, &H80000000, &H80000001, &H80000002, &H80000003, &H80000005, &H80000006) _
(Int ((Instr("HKCR,HKCU,HKLM,HKU ,HKCC,HKDD", hive) + 4) / 5))
End Function
'Name : NewDictionary -> Creates a new dictionary object.
'Parameters : None ->
'Return : NewDictionary -> Returns a dictionary object.
Function NewDictionary
Dim dict
Set dict = CreateObject("scripting.Dictionary")
dict.CompareMode = vbTextCompare
Set NewDictionary = dict
End Function
'Name : DQ -> Place double quotes around a string and replace double quotes
' : -> within the string with pairs of double quotes.
'Parameters : stringValue -> String value to be double quoted
'Return : DQ -> Double quoted string.
Function DQ (ByVal stringValue)
If stringValue <> "" Then
DQ = """" & Replace (stringValue, """", """""") & """"
Else
DQ = """"""
End If
End Function
'Name : IsoDateTimeString -> Generate an ISO date and time string from a date/time value.
'Parameters : dateValue -> Input date/time value.
'Return : IsoDateTimeString -> Date and time parts of the input value in "yyyy-mm-dd hh:mm:ss" format.
Function IsoDateTimeString(dateValue)
IsoDateTimeString = IsoDateString (dateValue) & " " & IsoTimeString (dateValue)
End Function
'Name : IsoDateString -> Generate an ISO date string from a date/time value.
'Parameters : dateValue -> Input date/time value.
'Return : IsoDateString -> Date part of the input value in "yyyy-mm-dd" format.
Function IsoDateString(dateValue)
If IsDate(dateValue) Then
IsoDateString = Right ("000" & Year (dateValue), 4) & "-" & _
Right ( "0" & Month (dateValue), 2) & "-" & _
Right ( "0" & Day (dateValue), 2)
Else
IsoDateString = "0000-00-00"
End If
End Function
'Name : IsoTimeString -> Generate an ISO time string from a date/time value.
'Parameters : dateValue -> Input date/time value.
'Return : IsoTimeString -> Time part of the input value in "hh:mm:ss" format.
Function IsoTimeString(dateValue)
If IsDate(dateValue) Then
IsoTimeString = Right ("0" & Hour (dateValue), 2) & ":" & _
Right ("0" & Minute (dateValue), 2) & ":" & _
Right ("0" & Second (dateValue), 2)
Else
IsoTimeString = "00:00:00"
End If
End Function
'Name : LogMessage -> Parses a message to the log file based on the messageType.
'Parameters : messageType -> Integer representing the messageType.
' : -> 0 = message (writes to a ".csv" file)
' : -> 1 = error, (writes to a ".err" file including information relating to the error object.)
' : -> 2 = error message (writes to a ".err" file without information relating to the error object.)
' : message -> String containing the message to write to the log file.
'Return : None ->
Function LogMessage(messageType, message)
Dim prefix, logType
prefix = hostName
Select Case messageType
Case 0
logType = "csv"
Case 1
logType = "err"
message = "Error " & Err.Number & " (Hex " & Hex(Err.Number) & ") " & message & ". " & Err.Description
Case Else
LogType = "err"
End Select
If Not LogToCentralFile(scriptLogPath & "." & logType, hostName & "," & message) Then
Exit Function
End If
End Function
'Name : LogToCentralFile -> Attempts to Appends information to a central file.
'Parameters : logSpec -> Folder path, file name and extension of the central log file to append to.
' : message -> String to include in the central log file
'Return : LogToCentralFile -> Returns True if Successfull otherwise False.
Function LogToCentralFile(logSpec, message)
Dim attempts, objLogFile
LogToCentralFile = False
'Attempt to append to the central log file up to 10 times, as it may be locked by some other system.
attempts = 0
On Error Resume Next
Do
Set objLogFile = objFSO.OpenTextFile(logSpec, ForAppending, True)
If Err.Number = 0 Then
objLogFile.WriteLine message
objLogFile.Close
LogToCentralFile = True
Exit Function
End If
Randomize
Wscript.sleep 1000 + Rnd * 100
attempts = attempts + 1
Loop Until attempts >= 10
On Error Goto 0
End Function
'Name : PromptStart -> Prompt when script starts.
'Parameters : None ->
'Return : None ->
Function PromptStart
MsgBox "Now processing the " & DQ(Wscript.ScriptName) & " script.", vbInformation, scriptBaseName
End Function
'Name : PromptEnd -> Prompts when script has completed.
'Parameters : None ->
'Return : None ->
Function PromptEnd
MsgBox "The " & DQ(Wscript.ScriptName) & " script has completed successfully.", vbInformation, scriptBaseName
End Function
'Name : PromptError -> Prompts when an unexpected script error occurs.
'Parameters : None ->
'Return : None ->
'Function PromptEnd
' MsgBox "Error " & Err.Number & " (Hex " & Hex(Err.Number) & "). " & Err.Description, vbCritical, scriptBaseName
'End Function -
How to make this faster?? read millions of record from txt file
Hi there,
I got an issue. There is a txt file contains 2 million records, I also got another file contains over 10000 numbers. Now, I need to compare this 10000 numbers with that 2 million records if any records contains a number which belongs to 10000 number set, i retrieve this record and keep it. later on, when i finish the comparison i'll write all the result records into a txt file.
What kind of data structure shall i use to keep the records and numbers? how to make the comparison quicker? Any idea will do!
Thanks!if i were to do it, i will insert bout the records into the db. then do an sql statement on the two tables to get the results. Then get the rs and output it to another text file.
just my opinion. not sure if this is faster.
Message was edited by:
clarenceloh -
How to read the second line in a .txt file with bufferedReader?
hi,
i am not the best in speaking english and programming java :)
so, just try to make sense of my question:
Im using a BufferedReader to read a .txt file.
the .txt file has 5+ different lines, and each line has 6 tokens (separated with ; )
My java file has 6 textFields and each textfield is filled with one of the 6 different tokens.
and my problem is:
I want my buffered reader to read the next line (with 6 new different tokens) by pressing a button.
if somethings not understandable, just ask :)maybe its easier to help me, when i publish my code, so here it is:
(its my version, without Thof's code. Sorry, but the comments are the most in german)
/* userdata.java */
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
public class userdata extends Frame {
//-----------------------------------KlassenVariablen------------------------------------------------
private JPanel panel = new JPanel ();
String tokId = "";
String tokName= "";
String tokAge= "";
String tokTel= "";
String tokMail= "";
String tokText= "";
BufferedReader br;
String zeile;
StringTokenizer st;
String delim = ";";
//---------Buttons f?r Panel 1-------------------------
Button first = new Button("|< First");
Button back = new Button("< Back");
Button next = new Button("Next >");
Button last = new Button("Last >|");
//---------Buttons f?r Panel 3-------------------------
Button neu = new Button("New");
Button safe = new Button("Safe");
Button refresh = new Button("Refresh");
//--------Labels f?r Panel 2-----------------------------
Label lid = new Label("ID",Label.LEFT);
Label lname = new Label("Name",Label.LEFT);
Label lage = new Label("Age",Label.LEFT);
Label ltel = new Label("Tel.",Label.LEFT);
Label lmail = new Label("E-Mail",Label.LEFT);
Label ltext = new Label("Spruch",Label.LEFT);
Label lub = new Label("Last Button",Label.LEFT);
TextField id = new TextField();
TextField name = new TextField();
TextField age = new TextField();
TextField tel = new TextField();
TextField mail = new TextField();
TextField text = new TextField();
TextField usedbutton = new TextField();
//--------ActionEvent bla sachen eben--------------------
public static void main (String[] args) throws IOException {
userdata wnd = new userdata();
wnd.setVisible(true);
public userdata() throws IOException {
//--------------------------------Layout mit panel bestimmung--------------------------------------
setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
add(BorderLayout.NORTH ,p1);
add(BorderLayout.CENTER , p2);
add(BorderLayout.SOUTH , p3);
//-------------------------------Funktionslose Buttons in PANEL 1------------------------------------
p1.add(first);
p1.add(back);
p1.add(next);
p1.add(last);
p1.add(usedbutton);
//--------------------------------Funktionierende Textfelder in PANEL 2------------------------------
Panel labelpanel = new Panel();
p2.setLayout(new GridLayout(7,3));
p2.add(lid);
p2.add(id);
p2.add(lname);
p2.add(name);
p2.add(lage);
p2.add(age);
p2.add(ltel);
p2.add(tel);
p2.add(lmail);
p2.add(mail);
p2.add(ltext);
p2.add(text);
p2.add(lub);
p2.add(usedbutton);
//--------------------------------------Buttons in PANEL 3-----------------------------------------
p3.add(neu);
p3.add(safe);
p3.add(refresh);
//--------------------------------BufferedReader -------------------------------------------------
readData();
//--------------------------------Panel 2 TextField-----------------------------------------------
fillForm();
//================================ActionPerformed==================================================
first.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("First");
usedbutton.setText("First");
back.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Back");
usedbutton.setText("Back");
next.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Next");
usedbutton.setText("Next");
last.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Last");
usedbutton.setText("Last");
neu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("New entry");
usedbutton.setText("New");
safe.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Now Saving, do not turn off!");
usedbutton.setText("Save");
//-----------------refresh
refresh.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
try{
readData();
}catch( IOException ioe){
System.out.println("Fehler beim lesen aus Datei");
fillForm();
usedbutton.setText("Refresh");
//=============================================================================Button Funktionen!!!
pack();
//--------------------------------WindowsListener hinzuf?gene--------------------------------------
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent event)
setVisible(false);
dispose();
System.exit(0);
//-----------------------------------readData() - > Buffered Reader in aktion! --------------------
private void readData() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("My .txt File with path"));
String zeile;
StringTokenizer st;
String delim = ";";
zeile = br.readLine();
st = new StringTokenizer(zeile, delim);
st.hasMoreTokens();
//System.out.println (st.nextToken());
tokId = new String(st.nextToken());
tokName = new String (st.nextToken());
tokAge = new String (st.nextToken());
tokTel = new String (st.nextToken());
tokMail = new String (st.nextToken());
tokText = new String (st.nextToken());
//--------------------------fillForm() - > f?llt die TextFelder aus!--------------------------------
private void fillForm(){
id.setText(tokId);
name.setText(tokName);
age.setText(tokAge);
tel.setText(tokTel);
mail.setText(tokMail);
text.setText(tokText);
} -
Help. Why has the end content of my Indesign file disappeared?
Hi. I'm using Indesign 5.5 on a Windows 7 PC.
I'm currently making an epub in Indesign. It is a long flowing document on a single page. I'm separating chapters with Style headings. I've been slowly going through it and adding the image files. I've reached page 66 and the end of my document is missing. I've gone back through earlier versions and in each have seen that there is a little bit more of my text. Very puzzled I tried to copy the missing text onto the end of my current document and it doesn't appear. I'm now wondering if there is a 66 page size limit?
If there is what can I do to complete my epub. Start a new file for the second half of my book and somehow merge them?
Any help appreciated as this unforseen problem is like a kick in the guts.
Thanks.You need to back up and learn some basics before you get to far into ePub. (Sorry to be blunt)
- Click the red overset symbol to load all the overset text.
- Add one page to the end of the document.
- At that new page, Hold the Shift key while clicking inside the page margin to flow all the overset text, adding new pages as needed. (You should see the laoded curser change appearance when the shift key is held)
Maybe you are looking for
-
Help connecting phone hotspot to computer.
I am trying to use Droid X as hot spot to my laptop. Not sure how to set the computer so that it will recognize the droid...
-
Can you backup in recovery mode?
Since I'm a moron I forgot my passcode for my ipod. I figured I'd just back it up and restore it, since I don't wanna lose all my stuff. But now my ipod is in recovery mode and it says my only option would be to restore it, but I don't have my ipod b
-
I Have had CS3 on a windows desktop that has died and I now have a mac, will my licence allow me to download a mac version of CS3 or do I have to buy a new package and licence?
-
Resolving connectivity issues with Verizon 4G LTE JetPack 4510L
Device is showing ready but when you try to surf internet etc it will not connect and disconnects. Appears to be a connectivity problem and I have attempted a hard reset of the device, i have shut it down and re-seated the sim card. no change. please
-
my laptop died, is there a way to tranfer music purchased in ITunes from an ipad air to an ipod nano?