Inkinga enkulu ngefayela lokukopisha ama-hdf ahlanganisiwe ukuthi lingahamba kancane kakhulu.
import shutil shutil.copyfile("/hdfs/path/to/file", "/local/path/to/file")
Lo mugqa wekhodi ungenisa imojula yokuvala bese usebenzisa umsebenzi wokukopisha kusuka kuleyo mojula ukukopisha ifayela kusuka ku-HDFS kuya ohlelweni lwefayela lendawo.
Yini ama-hdfs
I-HDFS iwuhlelo lwamafayela olusabalalisiwe olunikeza isitoreji esinengozi, esiqinile, nesithembekile samasethi amakhulu edatha. Ibhalwe nge-Java futhi isebenza endaweni yesikhulumi se-Java.
Izindlela zokuhlanganisa amafayela
Kunezindlela ezimbalwa zokuhlanganisa amafayela kuPython. Indlela elula ukusebenzisa imojula yokuhlanganisa ifayela eyakhelwe ngaphakathi:
ngenisa i-filemerger
file1 = vula(“file1.txt”)
file2 = vula(“file2.txt”)
merge_file(file1, file2)
phrinta ("Ifayela lihlanganisiwe!")
Sebenza ngamafayela
Ku-Python, ungasebenza ngamafayela ngokungenisa imodyuli efanele. Isibonelo, ukungenisa imojuli yokuphatha ifayela, uzosebenzisa umugqa olandelayo:
kusuka kufayela Ukuphatha ifayela lokungenisa
Uma usungenise imojuli, ungakwazi ukufinyelela amafayela ngokusebenzisa amagama awo njengokuguquguquka. Isibonelo, uma ubufuna ukufinyelela ifayela elithi myfile.txt ohlwini lwakho lwamanje, ubungasebenzisa umugqa olandelayo:
myfile = Ifayela(“myfile.txt”)