Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

meixiang6

@meixiang6
About
Posts
18
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Parsing Text Files and Spliting on '>'
    M meixiang6

    It works, thank you so much!

    Java java json help tutorial

  • Parsing Text Files and Spliting on '>'
    M meixiang6

    Thanks so much! I tried compiling and I am getting complaints as follows, any ideas? Sorry I am new to JAVA and cant figure out how to fix it. thanks again! SplitFiles.java:24: cannot find symbol symbol : method charAt(int) location: class java.lang.Object if (List.get(i).charAt(0) == '>') ^ SplitFiles.java:27: cannot find symbol symbol : method replace(java.lang.String,java.lang.String) location: class java.lang.Object getFileName = List.get(i).replace(">", ""); ^ SplitFiles.java:52: cannot find symbol symbol : method charAt(int) location: class java.lang.Object if (List.get(k).charAt(0) == '>') ^ SplitFiles.java:74: cannot find symbol symbol : method charAt(int) location: class java.lang.Object if (List.get(k).charAt(0) == '>')

    Java java json help tutorial

  • Parsing Text Files and Spliting on '>'
    M meixiang6

    Thanks so much for your help! Just one small point the code you wrote here "for (k = i+1; k " is missing the end part any chances you know what the ending should be? Thanks again!

    Java java json help tutorial

  • Parsing Text Files and Spliting on '>'
    M meixiang6

    Hi can some kind person help with this JAVA Q on parsing text files: INPUT TEXT (FASTA) FILE: >AB485992 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT >AB485993 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT >AB485994 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT >AB485922 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT >AB485912 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT >AB485942 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT I need JAVA Code that parses the input file and generates 6 files each file contains file is labelled after the '>' and before the space ie file 1 will be named AB485992 and that file will contain the text between the '>' and the following '>' ie: >AB485992 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT file 2 will be labelled: AB485993 and it contents >AB485993 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT file 3 will be labelled: AB485993 and it contents >AB485994 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT and so on for all six files So far I have code that parses out the word after '>' ie the file label and prints those to args file like below, can some kind person PLEASE show me how to parse the INPUT file and generate the 6 seperate files as described above each file labeled after the '>' eg file1, labelled AB485992 and so on for the 6 files >AB485992 some text ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT ATTGGGAATGGAGGGAAATAAATGACTGGATGGTCGCTGCT THANKS SO MUCH! import java.io.*; import java.util.Scanner; public final class ReadWithScanner { public static void main(String... aArgs) throws FileNotFoundException { File f = new File("args"); f.delete(); ReadWithScanner parser = new ReadWithScanner("file.text"); parser.processLineByLine(); log("Done."); } public ReadWithScanner(String aFileName){ fFile = new File(aFileName); } public final void processLineByLine() throws FileNotFoundException { Scanner scanner = new Scanner(fFile); try { while ( scanner.hasNextLine() ){ processLine( scanner.nextLine() ); } } finally { scanner.clo

    Java java json help tutorial

  • using vectors to parse text delimited files in C++
    M meixiang6

    Thanks stuart, it works nicely.

    C / C++ / MFC c++ perl ios graphics linux

  • using vectors to parse text delimited files in C++
    M meixiang6

    I want to use vectors in C++ on a linux box to parse a tab delimited text file and parse something in the second column. In perl I could do something like this: In perl: #!/usr/local/bin/perl while(<>) { chomp; ($first_col, $second_col, $third_col)=split(/\t/,$_); if ($second_col =~ m/$target/g){ print "$second_col\n"; } } In C++ I have the following 2 D code, can someone modify it to parse out text in the column 2 using vectors? Thanks for everyones help in advance.... #include #include #include #include #include using namespace std; int main() { ifstream ff( "test.txt", ios::in ); if ( !ff.is_open() ) return -1; string name; vector names; while( !ff.eof() ) { ff >> name; if (!ff.eof()) names.push_back( name ); } copy (names.begin(), names.end(), ostream_iterator(cout,"\n")); return 0; }

    C / C++ / MFC c++ perl ios graphics linux

  • check existence of file in C++
    M meixiang6

    I will give it a try tommorrow...thanks!

    C / C++ / MFC question c++ perl database

  • Ugly C code
    M meixiang6

    Thanks Stuart, very useful..

    C / C++ / MFC help question perl

  • Ugly C code
    M meixiang6

    Thank you so much grzkas!:thumbsup:

    C / C++ / MFC help question perl

  • check existence of file in C++
    M meixiang6

    After a lot of wrong examples from googling the web, I finally find something that works: myFileName = file; inp.open(myFileName.c_str(), ifstream::in); inp.close(); if(inp.fail()) { inp.clear(ios::failbit); cout << "No File found " << myFileName.c_str() << endl; exit(5); } else { cout << "Found File" << myFileName.c_str() << endl; } Thanks, hope this might help someone else... Bye the way is this board only for Visual C++ or can someone working on Linux with C++ ask Qs?

    C / C++ / MFC question c++ perl database

  • check existence of file in C++
    M meixiang6

    PathFileExists is a windows API and I am running C++ in linux so it doesnt work as far as I know and have been trying unless I goofed up...

    C / C++ / MFC question c++ perl database

  • check existence of file in C++
    M meixiang6

    #include #include #include #include #include // getcwd() definition #include // MAXPATHLEN definition using namespace std; int main() { string database; cout << "Select full path of Database" << endl; cin >> database; How do I check the existence of a file in C++? In perl it would be something like: if (!database){ print "No database found\n"; exit; } I tried looking online for hours but all the suggestions didnt work so far.. Thanks in advance!

    C / C++ / MFC question c++ perl database

  • Ugly C code
    M meixiang6

    Following to my question yesterday, is there anything that can be done to clean up the c code below which works fine but looks ugly especially the strcat's? The program parses a file containing a list of files and then runs a command on each. I can do a similar thing in perl like this a couple of lines but in C its looks ugly and I think its because I am a newbie...any comments will be appreciated.... thanks in advance for everyones help In perl: #!/usr/bin/perl while(<>){ chomp; $cmd="qsub -P 9999 -wd -e $_\.error -b y /usr/local/projects/bin/program -i $_ -type p -terms -lookup -o $_\.qsub"; print "$cmd\n"; } in C: #include #include #include #include #include #include int main(int argc, char *argv[]) { char * cwd = getcwd(0,0); char pro[10000]; char str[1000]; char* nl; if (argc < 3) { printf("\n\nPlease supply a file containing a list of single file names follow by project code\n"); exit(5); } FILE *f; f = fopen(argv[1], "r"); if(!f) { printf("Couldn't open file.txtn"); return 1; } while(fgets(str, 1000, f)) { nl = strrchr(str, '\r'); if (nl) *nl = '\0'; nl = strrchr(str, '\n'); if (nl) *nl = '\0'; strcpy(pro, "qsub -P "); strcat(pro, argv[2]); strcat(pro, " -wd -e "); strcat(pro, cwd); strcat(pro, "/"); strcat(pro, str); strcat(pro, ".error -b y /usr/local/projects/bin/program -i "); strcat(pro, cwd); strcat(pro, "/"); strcat(pro, str); strcat(pro, " -type p -terms -lookup -o "); strcat(pro, str); strcat(pro, ".qsub"); printf (pro); system(pro); } }

    C / C++ / MFC help question perl

  • Please please help with this simple Q from a C++ newbie
    M meixiang6

    Thanks Stuart, I got it working with this, not sure if the code is right thou but it works... #include #include int main() { FILE *f; char string[1000]; char str[1000]; f = fopen("file.txt", "r"); if(!f) { printf("Couldn't open file.txtn"); return 1; } while(fgets(str, 1000, f)) { /* printf("%s", str); */ strcpy (string, "ls -la "); strcat (string, str); system (string); } fclose(f); return 0; }

    modified on Thursday, February 19, 2009 8:56 PM

    C / C++ / MFC c++ perl linux help tutorial

  • Please please help with this simple Q from a C++ newbie
    M meixiang6

    thanks Stuart for the information, I am a very new newbie and have no idea how that looks like in C, any chance of someone writing that in C ? apologizes for the inconvenience

    C / C++ / MFC c++ perl linux help tutorial

  • Please please help with this simple Q from a C++ newbie
    M meixiang6

    Thanks very much Stuart! Any chance of typing the entire code in C as well? thanks a lot again!

    C / C++ / MFC c++ perl linux help tutorial

  • Please please help with this simple Q from a C++ newbie
    M meixiang6

    Please please help with this simple Q from a C++ newbie....I spent hours trying to find the answer online... I want to run this on a linux box. Open a file containing a list of file names and then run a linux commands on each of the list for example: The file contains a list of files names eg: test test1 test2 test3 How do I code in C so that it opens the file and then foreach of the elements do a system command eg: ls in perl it would be something like: #!/usr/local/bin/perl while(<>){ chomp; $cmd="ls $_"; system($cmd); print "$cmd\n"; } Thanks in advance!

    C / C++ / MFC c++ perl linux help tutorial

  • Please help me with this simple C question
    M meixiang6

    Please please help with this simple Q from a C newbie....I spent hours trying to find the answer online... I want to run this on a linux box. Open a file containing a list of file names and then run a linux commands on each of the list for example: The file contains a list of files names eg: test test1 test2 test3 How do I code in C so that it opens the file and then foreach of the elements do a system command eg: ls in perl it would be something like: #!/usr/local/bin/perl while(<>){ chomp; $cmd="ls $_"; system($cmd); print "$cmd\n"; } Thanks in advance!

    C# question perl linux help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups