Use python to De-Spanglishification A certain website offers English translations of foreign lyrics. When I search for the lyrics to my favorite Latin jam, I get the following result: La Bamba The Bamba Para bailar la Bamba, To dance the Bamba, para bailar la Bamba, to dance the Bamba, se necesita una poca de gracia. one needs a bit of grace. Una poca de gracia para mí, para ti, A bit of grace for me, for you, ya arriba, ya arriba, now come on, come on, These results, which have been stored in the provided file Bamba-Spanglish_v1.txt, contains the Spanish and English lyrics interlaced on odd and even lines. What I really want is a pair of files Bamba-Spanish.txt and Bamba-English.txt which contain the Spanish and English lyrics respectively. Write a program that separates the given file into the two separate files as described.
package filereadwrite;
import java.io.*;
public class FileReadWrite {
public static void main(String[] args) throws Exception
{
FileReader readerFile = new
FileReader("Bamba-Spanglish_v1.txt");
FileWriter writerSpanish = new
FileWriter("Bamba-Spanish.txt");
FileWriter writerEnglish = new
FileWriter("Bamba-English.txt");
BufferedReader bufferedReader = new
BufferedReader(readerFile);
String line;
int i=0; //will track the odd and even lines
while ((line = bufferedReader.readLine()) != null) {
if(i%2==0){ //if even
writerSpanish.write(line);
writerSpanish.write("\r\n"); //to get to newline
}
else{ //if odd
writerEnglish.write(line);
writerEnglish.write("\r\n");
}
i++;
}
readerFile.close();
writerSpanish.close();
writerEnglish.close();
}
}
Use python to De-Spanglishification A certain website offers English translations of foreign lyrics. When I search...