Manipulating text file

I have a text file that look something like this:
[21/06/07] System DEBUG * BA_LOG_OUTPUT
System DEBUG Random text  Random text
System DEBUG Random text  Random text
System DEBUG Random text  Random text
System DEBUG Random text  Random text <?xml version=�1.0� encoding=�UFT-8�?>
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
[21/06/07] System DEBUG * BA_LOG_OUTPUT
System DEBUG Random text  Random text
System DEBUG Random text  Random text
System DEBUG Random text  Random text
System DEBUG Random text  Random text <?xml version=�1.0� encoding=�UFT-8�?>
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tony</to>
<from>James</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
[21/06/07] System DEBUG * BA_LOG_OUTPUT
System DEBUG Random text  Random text
System DEBUG Random text  Random text
System DEBUG Random text  Random text
System DEBUG Random text  Random text <?xml version=�1.0� encoding=�UFT-8�?>
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Amy</to>
<from>Tobi</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>I am trying to read the file so that it picks the welled formed XML e.g:
<?xml version=�1.0� encoding=�UFT-8�?>
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<?xml version=�1.0� encoding=�UFT-8�?>
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tony</to>
<from>James</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Amy</to>
<from>Tobi</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>There is a pattern in the file, the line <?xml version=�1.0� encoding=�UFT-8�?>Always start on the 4th line after BA_LOG_OUTPUT line
This is my code so far:
BufferedReader in = new BufferedReader(new FileReader(file));
String line = null;
Pattern p = Pattern.compile( �BA_LOG_OUTPUT� );
StringBuffer sb = new StringBuffer();
while((line = in.readLing()) != null){
   Matcher m = p.matcher(line);
    while(m.find()){
         System.out.println( line );
How do I make it so it goes 4 line down so it can find the line <?xml version=�1.0� encoding=�UFT-8�?> and start reading the xml file?

Use
Pattern p2 = Pattern.compile( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
               System.out.println(""+p2.pattern());Escape the quotes.

Similar Messages

  • Manipulating Text Files

    Hello
    I have about 100 text log files generated by SQLLDR. Each log file has a number of successful and rejected records denoted in the file. I want to extract this information out from each file. Beside from opening each file up and looking at each file manuanlly, I want to use PERL or something else to automatically read each file and extract only the information I want. I can then use this information and insert it into a table.
    Is there a tool I can use to manipulate(extract) textual information and append all the extracted information into one text file or maybe insert into a table. Thanks in advance.

    What about loading it as it is with sqlloader and then manipulating it with sql ?

  • Text file manipulation before load to ODS

    Hello Experts,
    I have a text file with 3 fields(comma separated): GLCode (Number), Desc1 (Char),
    Desc2(Char) and need to load it into BW.
    My Text file looks like:
    1011.00,"Mejor PC Infrastructure","This line is ok."
    1012.00,"Telephone Equipment $","This line ends in next line.    Need to add next line,
    1)Need to change the equipment immediately.
    2)Take immediate action"
    1013.00,"V1 Major Computer Server Infrastructure # Equip","For purchases
    of components that make up the company's network, such as servers, hubs, routers etc."
    1014.00,"Flash Drive","Need to provide all IT Developer"
    This is how file looks like. Now I need the followings:
    1. Need to remove the space and need to adjust the splitted line into one. Say here
    line/record 2 is splitted into 3 lines and need to adjust in 1 line.
    2. In Line 5 (Record 3) data splitted into 2 lines and need to make 1 line.
    3. Need to remove bad characters.
    4. Load into ODS after cleanup.
    Need guidance, example.
    Thank you.
    Regards,
    Bhakta
    Could someone help me please how to proceed ?

    Hi,
    Go to Details tab in monitoring.
    Just check for any packages are in yellow.
    If any package i yellow then right click and take the Update manually option for that package only.
    Or else you have to delete the request from the target and make the request in to red in monitor under Status tab.
    Now you can try to load the data.
    This is because of IDocs not processed successfully.
    Regards,
    Venkat

  • Transfer time stamp from text file into MS Access thru Labview

    Hello everyone,
    I am Cruz; Long time listener, First time caller.
    I am currently monotoring data being collected by an oven. The data is stored in a text file. I am using Labview to take the data from the textfile and place it in an MS access DB for manipulation. The first three columns of the text file are the time stamp of data. When i transfer the data into Access i cant get the first three columns to display as a time stamp. Can have some pointers on what how to get the first three columns to display correctly.
    Additional info:
    the text file is a 1D array that gets overitten with every new mesurement tanken. the transfer to Acces is to not loos any of the information and to better manipulate the data into forms and such.
    Running Labview 2010
    attached is code and text file.
    Any help is greatly appreciated.
    Attachments:
    Oven test other.vi ‏16 KB
    datalog032010003.txt ‏1 KB

    Your first mistake is reading the file as DBL. Your first three columns are obviously not numeric values. Did you ever look at the output array? Read it as strings. Second, you would need to combine those first three columns to create an actual time stamp before you write to the db. Unless of course you have one column for date, one column for time, and one column for AM/PM. I would not recomend that type of structure in the db.

  • Writing HTML data in TEXT File

    I am writing HTML content in TEXT file ...I read it in a string and then write using PrintStream...
    But it writes all content on one line ..I want to write it as it was in source HTML file...

    Perchance, the OP is referring to the lack of carriage returns in his outputted data, and querying where they have absconded to? An analysis of his posts to date reveals that he has read the contents of a File into a String variable, and wants to write the (presumably modified) String back to a file (uncertain as to whether this is the same file or a different one) In the process of outputting to said file, carriage returns previously contained in the original input file are not present in the output. I would hazard a guess that the OP does not want said carriage returns in the String to disappear.
    Is my analysis of the situation correct?
    An example of the code that you have written to date would be of extreme usefulness to us in aiding you in your noble quest.
    Without such a resource, I must rely on my intuition instead.
    Possible places that the carriage returns are being "dropped"
    1 - On reading in. Are you discarding carriage returns while building up your variable?
    2 - On manipulating. Are you processing this line by line, or reading it all into one large variable?
    3 - On output - are you using "print" or "println" in the output?
    I look forward to further correspondence with you sir
    kind regards,
    evnafets

  • How to make an applet to read the Text file present inside a jar

    Hi All,
    I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
    The applet code runs successfully when i run the applet in command prompt like
    {color:#ff0000}*java ReadFile*{color}
    And i am getting the needed results.
    Then i made a jar file with the applet code and text file as
    {color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
    Then i have inlcuded this applet inside a html file as
    {color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
    after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
    Applet is not recognizing trhe text file present inside the jar file.
    Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.

    what code in your applet gets the text file and reads it? are you using getResource or something similar?

  • Generating an XML formated text file

    Hi all
    I am a PL/SQL programmer and have no idea about XML :-(
    I am using ORACLE 10g and my application generates atleast 100 text files a day for customers. These files are manipulated using Utl_File package and gets data from the DB.These files are tab or comma delimeted. Now company wants to give an option to customers to get the same output in XML format. My understanding is that I need to get information from customers first to make the report template for them and then use some XML parser to get data from DB and give an output using that customer's specific template.
    I wanna know, if there is any whitepaper or manual that can guide me step by step. I just need to make an idea how the things can go togather and the sequence of operation. I also wanna use only PL/SQL and not Java at this time.
    Rashid
    Message was edited by:
    rashid68

    check it out at http://www.orafaq.com/faqxml.htm

  • From an Oracle form, I want to read a text file.

    From an Oracle form, I want to read a text file. In the form on a button press I have:
    declare
    in_file Text_IO.File_Type;
    linebuf VARCHAR2(1800);
    filename VARCHAR2(30);
    BEGIN
    filename:=GET_FILE_NAME('U:\ora_devl\pps\work\a.txt', File_Filter=>'Text Files (*.txt)|*.txt|');
    in_file := Text_IO.Fopen(filename, 'r');
    LOOP
    Text_IO.Get_Line(in_file, linebuf);
    -- :text_item5:=:text_item5||linebuf||chr(10);
    Text_IO.New_Line;
    END LOOP;
    EXCEPTION
    WHEN no_data_found THEN
    Text_IO.Put_Line('Closing the file...');
    Text_IO.Fclose(in_file);
    END;
    It gets an ORA-302000. I suspect the problem starts with the GET_FILE_NAME because when I comment out everything but that, It processes endlessly never ending.
    Forms [32 Bit] Version 11.1.1.3.0 (Production)
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    What can you tell me? Thanks

    GET_FILE_NAME will try to open an "Open File" dialog on the server, which obviously can't happen. If you want to use that type of behavior you need to use WebUtil and the function CLIENT_GET_FILE_NAME. Example:
         filename := CLIENT_GET_FILE_NAME('C:\', File_Filter=> 'Text Files (*.txt)|*.txt|All Files (*.*)|*.*|', dialog_type=> OPEN_FILE);Refer to the Builder Online help for more details. You can also refer to the demo which is available here:
    http://www.oracle.com/technetwork/developer-tools/forms/downloads/index.html
    More information here:
    http://www.oracle.com/technetwork/developer-tools/forms/webutil-090641.html
    Also, it appears that you are attempting to use a mapped drive ("U"). Although this can be made to work, it is not recommended and in some cases will not be supported. If you need access to remote files, you should use some other mechanism to bring the file to the local machine before manipulating it.

  • Variable text files in CS 5.5 data merge

    I have a document that I need to change the text in the document based on a variable in the data file that is being used for the data merge. For example if the are in group A the get letter from text document A, if they are in group B they get the letter from text document B.
    Can the data merge in CS 5.5 do this?

    not with text and not by itself, but a solution is workable.
    indesign's data merge can't place text files as if they were merging pictures, but it can place pictures from jpg, eps, pdf... if the text which changed was a picture, say a PDF, then this would be fine.
    as to telling data merge what is variable, indesign won't parse the data as such... it'll just put the data wherever the placeholders were. if you want if/else statements, these need to be done in the excel file first prior to saving as a text file for indesign.
    so yes, what the OP wants is do-able, but not "off of the shelf" - some manipulation in excel is required.

  • Is there a way to import data in a spreadsheet or text file into Contacts v7?

    Is there a way to import data in a spreadsheet or text file into Contacts v7? I have a list of about 500 people and their email addresses in FileMaker Pro that I can export in a number of formats that can be manipulated. Is there any way to get those contacts into Contacts without entering them one at a time?

    I have answered my own question. I exported the data from a layout in FileMaker Pro containing the required fields as tab separated text. That produced a .tab file that Contacts wanted nothing to do with. However, when I changed the .tab in the file name to .txt, Contacts accepted it as a file to import (File/Import). I then identified the field in Contacts in which the data in each field in the txt file was to be placed and in it went! The trick was changing .tab to .txt in the name of the file exported by FileMaker Pro.

  • Adding large arrays to a text file as new columns

    I am trying to merge several large text data files into a single file in Labview 8.0.  The files are too large to read in all at once (9-15 million lines each), so decided I need to read them in as smaller chunks, combine the arrays, and write them to a new file.
    The reason there are three separate data files was for speed and streaming purposes in the project, and the users wanted the raw, unadulterated data written to file before any kind of manipulation took place. 
    My VI:
    1.  Takes a header generated from another VI and writes it to the output file.
    2.  Creates a time column based on sample rate and the total number of data points
    3.  Reads in 3 files that each have text data (each data point is 9 bytes wide, there are up to 15 million data points per file.
    4.  Each iteration of the for loop writes a chunk of 10 to 100 thousand points (Somewhere in there seems to be the fastest it will do), formatted with the time column on the left, then the three data columns, until it's done.  I haven't quite figured out how to write the last iteration if there are fewer data points than the chunk size.
    Anyways, the main thing I was looking for was suggestions on how to do this faster.  It takes about a minute per million points on my laptop to do this operation, and though I recognize it is a lot of data to be moving around, this speed is painfully slow.  Any ideas?
    Attachments:
    Merge Fast Data.vi ‏67 KB

    Thanks for the tip.  I put the constants outside the array and noticed a little improvement in the speed.  I know I could improve the speed by using the binary file VI's but I need the files as tab delimited text files to import them into MATLAB for another group to do analysis.  I have not had any luck converting binary files into text files.  Is there an easy way to do that?  I don't know enough about binary file systems to use them.  I looked at the high speed data logger examples but they seemed complicated and hard to adapt to what I need to do.  Creating the binary header file seemed like a chore. 
    I am up for more advice on the VI I posted, or suggestions on different ways to convert a binary file to a MATLAB readable text file.
    Thanks!

  • Tfman - text file manager, much different then others

    Tfman - text file manager.
    Performs operations on files through textual representation of file system.
    Textual representation is in the form of plain text, editable with any text
    editor and may contain multiple operations of every kind. Tfman can be
    used from command-line or from within Vim as multi-window file manager.
    It can be combined with tools like Sed or Awk.
    . written in C fo Unix-like operating systems
    . no dependencies (except gcc/clang and GNU Make for building)
    Features in short:
       - scan filesystem to create its textual representation
       - parse textual representation and perform retrieved operations
       - use favorite text editing tool to edit textual representation
       - scan, edit and parse in one step
       - use Tfman from command-line or from within Vim as multi-window file manager
       - integration with other decent text editors should be easy
       - available: brace expansion, globbing, entries grouping, whole directory operations and more
    Project's homepage:
    https://chiselapp.com/user/machel/repository/tfman/home
    Installation procedure (AUR or sources tarball) - see Project's homepage
    Documentation, sources, report issue - see Project's homepage
    Warning:
       Tfman is in an early state, it didn't receive sufficient testing yet. Please
       be carefull when manipulating sensitive data with it.
    Note:
       I do not know any file manager that manipulates file system in similar way.
       Therefore usefulness of this kind of approach is not proven.
       Help me prove it.
    Screenshots:
    Screenshot1
    New version pushed to AUR:
    - changing entry ownership and permissions now associated under one action tag
    - few other action tags changed
    - Quick Start Guide now available, see Project's homepage
    - bug fixes
    Last edited by machel (2014-07-15 11:48:48)

    machel wrote:I know it looks complex, but I believe it is not as complex as it seems to be although
    not as simple as I want it to be. Any ideas how to make it simpler are highly appreciated.
    Well, for start: Is there really a reason to use different character for directory and its subdirectories? As far as I can tell, you could just use '%' for all directories and decide what is top-level directory and what is subdirectory based on the indentation. Also, it would be nice to reserve '#' for comments, as it is common in many languages.
    machel wrote:2) Use action tags to specify operations. They apply to single entries, groups of entries or whole directories
    Here the complexity begins. There is 13 operations, if I counted it correctly in the man page. To be fair, some of them are just adding '*' enforce overwrites. Fine, that leaves us with about 9 operations to learn. I could probably do that But it would be better if it was less... Would it be possible to simplify operations that don't affect file location by allowing user to simply change the value in the text representation? It would probably require some kind of header (or some clever trickery), because the order of columns is not fixed, but it might be worth the trouble. You could also extend this to changing file times and perhaps other properties (those from '-F proper'). The linking and moving operators look good, with little exception of '))' - that just looks odd to me But that is definitely my personal taste... I'd prefer something like single '>'.
    machel wrote:3) Entry names and action operands - I believe using them is quite intuitive:
    Name relative to directory/subdirectory above:
      'name'
    If you want absolute name:
      '/name'
    If you want name relative to current working directory (where Tfman was invoked):
      './name'
    No problem with this, I like that.
    machel wrote:
    dolik.rce wrote:ability to execute commands on the files/directories
    What do you mean? Shell commands?
    Shell commands would be best, but generally just ability to execute command with given file/directory as input or parameter. Example usage would be something like this:
    # Dir
    file1 ^ sed -i -e 'some sed script here' becomes: sed -i -e 'some sed script here' < file1
    file2 ^% touch % becomes: touch file2
    The syntax is just an example, but in this case ^ would feed the file into the standard input of the command, and '^%' would replace '%' in commandline with the actual file name. For globing, command gets executed for each matching file.
    machel wrote:
    dolik.rce wrote:execute some actions conditionally
    Interesting idea. I must think about it.
    Tfman already have tags to stop parsing file, stop parsing line and goto next,
    disable whole dir/group or single entry, exclude entry from under directory/group,
    perform action on previous action's target, ignore errors.
    But it works unconditionally.
    I can imagine wanting to do something based on the properties of file or even based on output of external command. E.g. 'move file only if it's older then N days', or 'ask remote server if it has file X, move the file to directory upload/ when the command returns non-zero exit status'
    machel wrote:--- Tfm ---
    Remember about 'tfm' utility which is simple Tfman wrapper  scanning given directory,
    opening it in editor defined in EDITOR shell variable (Vim is default) and parsing
    result after you save and quit.
    It just compress 3 steps into 1.
    This is definitely handy, and probably only reasonable way to use tfman interactively. However, I'm not a vim-person - as I already said I'm lazy to remember anything, so you can imagine that learning enough vim commands to use it effectively would be a nightmare for me The same goes for tfmvi, I'm just not the target audience for that. But my EDITOR variable is usually set to nano, so I could easily use it with that, probably just with slightly more typing.

  • Manipulating a file's contents however I choose...

    without using a standard approach such as:
    Flie1, Flie2
    * Open a stream to read file1, searching for the item of interest to manipulate.
    * Manipulate the item of interest locally.
    * Open a stream to file2 and write the contents of file1 in order including the now manipulated item of interest.
    * Delete file1
    This approach may work well for small files but I am thinking of an approach that will be usable for files of any size. It would be unreasonable to use this methodology to manipulate a 100 MB text file. Thus I am interested in modifying the contents of a file and leaving all remaining contents I do not want to modify untouched.
    I just can not think of a way to do this.

    Always Learning wrote:
    jverd wrote:
    Always Learning wrote:
    I thought there was some mechanism in Java allowing the editing of a file without the need of involving additional files.There are other schemes. Some of them have been mentioned here. Which one is appropriate, and whether they are "better" than this scheme, depends on your requirements, >your constraints, your context, and your definition of "better."Do you have any suggestions. Not until I know what the problem with the current approach is.
    Perhaps "better" is relative to my thinkingYes. I've stated as much a couple of times already.
    Thus I ask, do you have any scheme you would like to share here within this thread?I can think of at least two off the top of my head. One of them was already mentioned explicitly in this thread: RandomAccessFile. Another approach would be to read the whole file into memory, manipulate the contents in-mem, and then write everything back out to the original file.
    As I already stated: Which of those (or other possible candidates) is better, and whether any of them are even "better" than the original approach, depends on your specific requirements and context.
    Perhaps I was analyzing the required amount of syntax and thought there may be a better scheme from a syntactical point of view.Wait. Your problem with the 2-file approach is how much code you have to write? Oy ve.

  • Text files into Object ArrayList

    I have another class reading line-for-line text file, send each line to a class object and that class splits the line into fields. An ArrayList holds the objects. No problem.
    Then, an almost similar setup. This time, the file is clusters. A blank line separates the records. Here's the code:
    * DBKlass.java
    * from file.io
    * a text file with blocks of data
    * "records" are 3-10 lines of text separated by blank-line-return
    * all lines read into an Arraylist<Klass> klasList
    *  file.io also added the micron character to any blank lines
    * pass a loaded ArrayList which is a long line-for-line storage
    *  of my file I read in to a field formater DBKlass
    * to make Objects of type Klass
    package org.vcbrad.mainframe;
    import java.util.ArrayList;
    import javax.swing.JOptionPane;
    public class DBKlass {
        ArrayList<Klass> klasList;  
        public DBKlass( ArrayList<String> al ) {
            if( al != null && al.size() >= 1 )
                loadDB(  al  );
            else
                JOptionPane.showMessageDialog(MainFrame.desktop,"File not found");      
        private void loadDB( final ArrayList<String> al ) {
            String fldSep = "\u00B5"; // unicode = ? micron
            int alSize = al.size();
    klasList = new ArrayList<Klass>();
            for (int i = 0; i < alSize; i++) {
                if(al.get(i).equalsIgnoreCase(fldSep)) {
                    String temp = al.get(     i+1        ) + "]";
                    al.set(i+1,temp);
            String coursework = "";
            for (String s : al) {
                coursework += s;
            String[] courses = coursework.split(fldSep);
            for (int i = 0; i < courses.length; i++) {
                System.out.println(courses);
    klasList.add( new Klass( courses[i] ) );
    * System.out displays what I want
    * Ex: LPE17]Koordination Hauswirt-schaftlicher Arbetisprocesse.
    * pass that line to the new Klass( String rowrecord );
    * and then ...
    * Klass k = klasList.get(0) ... .get(1) ... .get(2) etc.
    * ALL objects from klasList
    * have the only the last record from my original text
    My question: Am I defeating ArrayList with my look-ahead feature? I realize ArrayList is not synchronized. Or, do I need to write out to a new file, read it again to make my objects???
    Message was edited by:
    vcbrad
    OK, after spending a lot of time with my original problem I went back and made a method call to the ArrayList<Klass> from outside this class. For whatever reason, jumping and/or manipulating the the internal Iterator of ArrayList won't let me make Objects. And, trying to manipulate Strings twice just makes the logic hard to untangle. So, it works now. Baffling because I have an identical class that does work line-for-line manipulating Strings before adding myObjects to ArrayList<myObject>

    First of all: Take a deep breath, and feel your feet... Don't panic, and do not cross-post or re-post with more exclamation marks just to get some attention!
    What kind of data are you going to process in your program? Probably images. Have a look at how images are handled in a Java program. How you read them, and how you display them. Then decide on the type of data you are going to keep in which data structure.
    Figure out what you want to do.
    Take a peak at some java example classes and programs.
    Perhaps have a look at the java.awt.Image class. Just an idea...
    Kind regards

  • Text file on cldc

    hallo,
    can i create text file with text editor at pc than can be stored and manipulated on mobile phone.
    thanks very much

    i am assuming you are talking w.r.t j2me context
    we have a source folder called src and one resource folder res
    as you can see with the demos provided with WTK
    you can read any file at runtime
    suppose you created a xml file x.xml
    then put in res folder
    at runtime you can access using
    InputStream in =     getClass().getResourceAsStream("/x.xml");

Maybe you are looking for

  • Dunning Letters Customization

    Hi, I want to customize Dunning letter program. We have around 10 Operating Units. We want to build the customization for only US and UK operating units using BI Publisher. Rest of the operating units need to use the standard report.(text output.) 'D

  • How to insert data in tables using loops sql

    Oracle 10.2g using Oracle sql*plus Table student is create table student(id) as select distinct student_id from students_table;now desc student; will retrieve student ====== Name         Null?    Type =========================== ID                  V

  • How to create the C++ DLL for Windows Mobile and how to import it in C#

    Hi All,      Please can u guide me for creating DLL on C++ and using it in C#      1) Steps to create the DLL using C++ for Windows Mobile      2) And where to place the DLL after builiding to make use of it in my C# project Thanks in Advance!!! Than

  • Apply Latest Security Patches on Oracle Database 10g Express Edition (XE) ?

    Hi ! I have an Oracle Database 10g Express Edition (XE) version 10.2.0.1.0 running on a Microsoft Windows 2003 SP2 server. I need to find and install the latest security patches on this database. Can someone inform me where I can find these patches a

  • New computer and iPhone syncing to iTunes

    I bought a new computer and didn't backup old iTunes hard drive . Now iTunes won't sync with my iPhone. It sees it . I followed some instructions , I put all songs back in iTunes via 3rd party, transferred purchases, backup, restore to backup, my pho